Closed SMH110 closed 1 year ago
We tried setting up a new project with the same public dependencies that you have and the same Wallaby configuration and everything was working for us.
There are certainly parts of your Wallaby configuration that look incorrect but it should still work for you:
wallaby.js configuration
module.exports = function () {
var path = require("path");
process.env.BABEL_ENV = "test";
process.env.NODE_ENV = "test";
process.env.NODE_PATH +=
path.delimiter +
path.join(__dirname, "node_modules") +
path.delimiter +
path.join(__dirname, "node_modules/react-scripts/node_modules");
require("module").Module._initPaths();
return {
autoDetect: true,
tests: ["src/**/*.spec.js?(x)", "!src/**/*.Pact.test.ts"],
env: {
type: "jsdom"
}
};
};
Is there any reason that you're not using automatic configuration? the process.env
variables should be set by default and there should be no need for changing the NODE_PATH
variable. Also, the env.type: "jsdom"
won't do anything in this context; this needs to be set in your jest.config.js
.
The only thing I can think of is that perhaps your node_modules
has conflicting versions of jest installed. You may try removing node_modules
and yarn.lock
/ package-lock.json
and then reinstall to see if that fixes your problem.
Also, please try running npm list jest
to ensure a single version of jest is installed:
wallaby-3143@1.0.0 /Users/user/temp/wallaby-3143
├─┬ jest-pact@0.9.4
│ └── jest@27.5.1
├─┬ jest-watch-typeahead@0.6.5
│ └── jest@27.5.1 deduped
└─┬ react-scripts@5.0.1
├─┬ jest-watch-typeahead@1.1.0
│ └── jest@27.5.1 deduped
└── jest@27.5.1 deduped
If uninstalling/reinstalling your node modules does not help, can you please create a sample repo with steps for installing dependencies. Please make sure that the sample repo only has public dependencies.
Thanks for your help.
This what I go when I ran npm list jest
├─┬ jest-pact@0.9.0
│ └── jest@26.6.0
├─┬ jest-watch-typeahead@0.6.5
│ └── jest@26.6.0 deduped
└─┬ react-scripts@5.0.1
├─┬ jest-watch-typeahead@1.1.0
│ └── jest@27.5.1 deduped
└── jest@27.5.1
I think I know now the issue is caused by jest-pact
package.
And to answer your question why I am not using the automatic configuration is because I have some pact tests which they don't run on my local machine as I am using Windows. You can read more here if you like. so I had to exclude those pact tests
Hi 👋 For some reason I am gettting this error message on all my tests "global is not defined" This happend after updating
reactp-scripts
to the latest version (5.0.1)Wallaby diagnostics report