Running jest tests on node 16.15.0 fails with "Error: Unknown worker message type message"
See original GitHub issueWe have a long-lived NX monorepo hosting multiple angular apps/libs with a mix of karma and jest tests. While in the process of upgrading the docker image from node:12-slim
to node:16-bullseye-slim
, we’re seeing the following during our jest unit test runs, and it breaks our CI build.:
node:internal/event_target:912
process.nextTick(() => { throw err; });
^
Error: Unknown worker message type message
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
at new NodeError (node:internal/errors:372:5)
at Function.fail (node:internal/assert:20:9)
at Worker.[kOnMessage] (node:internal/worker:317:12)
at MessagePort.<anonymous> (node:internal/worker:201:57)
at l.invokeTask (/__w/1/s/node_modules/zone.js/fesm2015/zone-testing-bundle.min.js:13:7018)
at a.runTask (/__w/1/s/node_modules/zone.js/fesm2015/zone-testing-bundle.min.js:13:2427)
at u.invokeTask [as invoke] (/__w/1/s/node_modules/zone.js/fesm2015/zone-testing-bundle.min.js:13:8068)
at u (/__w/1/s/node_modules/zone.js/fesm2015/zone-testing-bundle.min.js:44:1053)
at h (/__w/1/s/node_modules/zone.js/fesm2015/zone-testing-bundle.min.js:44:1373)
at MessagePort.p (/__w/1/s/node_modules/zone.js/fesm2015/zone-testing-bundle.min.js:44:1667) {
code: 'ERR_INTERNAL_ASSERTION'
}
I modified our test runner to run all of the jest tests together (~45 of them) from a helper javascript with the following command:
try {
execSync(
`npx nx run-many --target=test --projects=${projects.join(',')} --parallel --max-parallel=3 --configuration=cicd`,
{
stdio: [0, 1, 2],
},
);
} catch (e) {
process.exit(e.status);
}
Relevant versions:
@nrwl/angular 13.10.3
@nrwl/cli 13.10.3
@nrwl/eslint-plugin-nx 13.10.3
@nrwl/jest 13.10.3
@nrwl/linter 13.10.3
@nrwl/nest 13.10.3
@nrwl/node 13.10.3
@nrwl/workspace 13.10.3
@types/jest 27.4.1
jest 27.5.1
jest-junit ^13.1.0
jest-mock ^27.5.1
jest-preset-angular ^11.1.1
ts-jest 27.1.4
Thoughts? Do these versions of things not work on node 16? Is there an upgrade path that will support it?
The problem does go away if I simply use node:14-bullseye-slim
as the base image.
Also, I have been able to replicate outside of the container locally on node v16.15.0. Some of the tests were placeholders as simple as:
describe('server/testing-nestjs', () => {
it('Has no tests', () => {
expect(true).toEqual(true);
});
});
Attempt to Fix by Upgrading Dependencies
I tried a couple of queries on google, this seems to be sort of the better one, and yet I can’t seem to find a connection to Jest itself
The solution in this link was to upgrade deps. I did spend a few days trying that in our case; however, it blew up our jest-preset-angular
configuration.
In the end, it wasn’t clear to me if I could run with jest v28.1.0, ts-jest 28.0.3, and jest-preset-angular 12.0.1 in nx 13.10.3. I decided to backtrack when I reached the point where it appeared that an object-oriented attempt to call an overridden method from the base in ng-jest-transformer.ts/_createConfigSet
wasn’t working, and I couldn’t get the tests to run. Specifically, I was getting a configSet.processWithEsbuild
is not a function error here.
I tried upgraded the following:
@types/jest 27.4.1 → 27.5.1
jest 27.5.1 → 28.1.0
jest-junit ^13.1.0 → ^13.2.0
jest-mock ^27.5.1 → ^28.1.0
jest-preset-angular ^11.1.1 → ^12.0.1
ts-jest 27.1.4 → 28.0.3
(From slack on the #angular channel with @gioragutt)
Issue Analytics
- State:
- Created a year ago
- Reactions:5
- Comments:6 (4 by maintainers)
Top GitHub Comments
it’s making a local release as described in the contributing guide.
which is essentially:
happy to help out if you got any more questions on it.
any luck @maxime1992 ?