aurelia / aurelia/documentation

Testing Components is out of sync with latest Aurelia

Open
#441 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
104
Forks
108
PR merge metrics
No merged PRs in 30d

Description

**I'm submitting a bug report**
https://aurelia.io/docs/testing/components#testing-a-custom-element

* **Library Version:**
"aurelia-cli": "^1.0.2",

**Current behavior:**
After running `au new` and pasting in the examples from the testing component page they fail with the error

```
 FAIL src/my-component.spec.js (5.961s)
● Console

console.error internal/process/next_tick.js:68
{ Error: Cannot find module 'C:\path\to\project\test\unit\src\my-component' from 'aurelia-loader-nodejs.js'
```

**Expected/desired behavior:**

It should be looking for the component in `src/my-component` and not `test/unit/src/my-component`

Changing the line
```
- .withResources('src/my-component')
+ .withResources('my-component')
```

Fixed the problem.

Note there is an info box for Karma that says "If you are using `karma` and your configuration already has a path for `'*': 'src/*'` set you may not need to use `src/`, and just `my-component`." It looks like for the default out-of-the-box that the `src/` prefix is not needed now for the default Jest configuration.

Contributor guide

Open the contributing guide

Research direction

Open the Testing Components page at aurelia.io/docs/testing/components#testing-a-custom-element and compare its custom-element example with a fresh `au new` project using the default Jest configuration. Check the `.withResources('src/my-component')` path and confirm the example resolves the component from `src/my-component` rather than `test/unit/src/my-component`; update the documentation example and verify the test passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation, testing-qa
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.