-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Description
Do you want to request a feature or report a bug?
Feature.
What is the current behavior?
I'm using Jest with Wallaby and due to how Wallaby loads files, My <rootDir> was different than expected only in Wallaby tests. That caused runtime errors only when running Wallaby:
[Error] Runtime error: ● Validation Error:
[Error] Module <rootDir>/config/polyfills.js in the setupFiles option was not found.
[Error] Configuration Documentation:
[Error] https://facebook.github.io/jest/docs/configuration.html
[Info] console.log: Protip: rootDir is C:\Users\jogol\.vscode\extensions\WallabyJs.wallaby-vscode-1.0.77\wallaby\runners\node
What is the expected behavior?
It would have been nice to have the resolved path that couldn't be found also printed alongside its descriptor. Perhaps changing the error to:
Runtime error: ● Validation Error:
Module <rootDir>/config/polyfills.js in the setupFiles option was not found.
Tried path: C:\Users\jogol\.vscode\extensions\WallabyJs.wallaby-vscode-1.0.77\wallaby\runners\node
Configuration Documentation:
https://facebook.github.io/jest/docs/configuration.html
If there are multiple paths that are tried, have them as a list?
Please provide your exact Jest configuration and mention your Jest, node,
yarn/npm version and operating system.
Jest version: 22.4.0
node: 9.5.0
npm: 5.6.0
OS: Windows 10 and Windows Server 2016
Jest config:
{
"collectCoverageFrom": [
"src/*/**/*.ts*",
"!src/Adapters/**",
"!src/External/**",
],
"globals": {
"ts-jest": {
"tsConfigFile": "./tsconfig.test.json"
}
},
"moduleFileExtensions": [
"js",
"ts",
"tsx"
],
"rootDir": "../../",
"setupFiles": [
"<rootDir>/config/polyfills.js"
],
"setupTestFrameworkScriptFile": "<rootDir>/test/unit/setup",
"testMatch": [
"<rootDir>/src/**/?(*.)test.ts?(x)"
],
"testEnvironment": "jsdom",
"testURL": "http://localhost",
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$"
]
}Wallaby config:
module.exports = () => ({
env: {
type: "node",
},
files: [
"package.json",
"test/unit/jest.json",
"config/polyfills.js",
"src/**/*.ts",
"!src/**/*.test.ts",
"src/**/*.tsx",
"!src/**/*.test.tsx",
"src/External/**/*.js",
],
filesWithNoCoverageCalculated: [
"src/BrowserMain/*",
"src/Adapters/**",
"src/External/**",
"src/*.tsx",
"src/*.ts",
],
hints: {
ignoreCoverage: /istanbul ignore next/,
},
setup: (wallaby) => {
const jestConfig = {
...require("./test/unit/jest.json"),
rootDir: __dirname,
};
console.log("Protip: rootDir is", jestConfig.rootDir);
wallaby.testFramework.configure(jestConfig);
},
testFramework: "jest",
tests: [
"src/**/*.test.ts",
"src/**/*.test.tsx",
],
});(The configs might not match up because I removed company-specific names. I promise they work!)