Closed dkent600 closed 6 years ago
Can you provide your test file?
@Alexander-Taran What test file? Do you mean this, that I referred-to in the original comment?
http://aurelia.io/docs/testing/components#testing-a-custom-element
In my jest config there is a setting
"testEnvironment": "node",
And it came from what Aurelia CLI does.. It may well be that not having it confuses aurelia under testing and there is wrong loader selected and everything goes sideways.. (-:
Here is what CLI produced for me:
"modulePaths": [
"<rootDir>/src",
"<rootDir>/node_modules"
],
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"transform": {
"^.+\\.(ts|tsx)$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "\\.spec\\.(ts|js)x?$",
"setupFiles": [
"<rootDir>/test/jest-pretest.ts"
],
"testEnvironment": "node",
"moduleNameMapper": {
"aurelia-(.*)": "<rootDir>/node_modules/$1"
},
"collectCoverage": true,
"collectCoverageFrom": [
"src/**/*.{js,ts}",
"!**/*.spec.{js,ts}",
"!**/node_modules/**",
"!**/test/**"
],
"coverageDirectory": "<rootDir>/test/coverage-jest",
"coverageReporters": [
"json",
"lcov",
"text",
"html"
],
"mapCoverage": true
},
"engines": {
"node": ">= 6.0.0"
},
"scripts": {
"start": "nps",
"test": "nps test"
},
Yeah. I just tried to remove it from my config and it blew up.. not the same error, but it is important..
Please refer to the issue I created on aurelia-framework: https://github.com/aurelia/framework/issues/869
@Alexander-Taran adding "testEnvironment": "node"
makes no difference for me (I think it was always in there).
the culprit is
"moduleNameMapper": {
"aurelia-(.*)": "<rootDir>/node_modules/$1"
},
see https://github.com/aurelia/framework/issues/869 for discoveries with the repro zip attached.
I propose to close this one in favor of https://github.com/aurelia/cli/issues/834
I'm submitting a bug report
Please tell us about your environment: Windows 10
Node Version: 9.4.0
NPM Version: 5.6.0
Language: javascript
Current behavior: When I run the test given here: http://aurelia.io/docs/testing/components#testing-a-custom-element I get the following error:
Note this is being thrown inside the
done
function (line 18).Some possibly-relevant package versions:
jest-pretest.ts:
Jest configuration:
The test command: "jest --no-cache"