Closed BrandonALittle closed 1 year ago
We were able to reproduce your problem. We've done some preliminary triage and haven't been able to determine why ts-node
isn't loading correctly.
For now, you can resolve the problem by adding nodeLinker: node-modules
to your .yarnrc.yml
file:
yarnPath: .yarn/releases/yarn-3.5.1.cjs
+ nodeLinker: node-modules
...
packageExtensions:
...
While this may not be ideal (i.e. having node_modules
), this is the work around we're suggesting at the moment. It's going to take us a bit longer to isolate the problem and determine if we can provide a fix some other way. Without better understanding the problem, we're not entirely sure if we can provide a fix or if this is a hard limitation.
Understood. I'm at least happy you were able to reproduce the issue, and I appreciate your time.
We're pretty set on using the PNP nodeLinker. A happy medium that does work is to use a JSDOC type annotation for the JS config file:
/** @type {import('jest').Config} */
const config = {
projects: [
...
],
}
module.exports = config
I'll try to get my team onboard with that in the meantime.
Thanks!
We've updated Wallaby to support loading jest
configuration with .ts
extension using Yarn 2 workspaces. Place update to Wallaby core v1.0.1425
, it should work for you.
Fantastic! Thank you!
I upgraded to the latest version 1.0.1427
and can confirm it's working.
Cheers
Issue description or question
In a
yarn 2
monorepo with workspaces, and ajest.config.TS
with aprojects
configuration, everything works just fine when runningyarn jest
. Wallaby, however, is unable to parse thejest.config.TS
, but is completely happy with ajest.config.JS
file.Again, no issue with running the tests via
yarn jest
. No issue running Wallaby with a JS jest config file. I want to use a TS jest config file, hence my problem. This is the trace output I see:The dependencies in the root
package.json
:jest.config.ts / jest.config.js
:.yarnrc.yml
packageExtensions (some of these settings might not be doing anything):Wallaby diagnostics report
{ editorVersion: '1.78.0', pluginVersion: '1.0.355', editorType: 'VSCode', osVersion: 'darwin 20.6.0', nodeVersion: 'v19.8.1', coreVersion: '1.0.1424', checksum: 'NTRjMWQ1ZTk4OTg5NjA2NDdmNGQ0NmZhMzFjNzJkZTgsMTY5NzI0MTYwMDAwMCww', config: { tests: [], files: [] }, packageJSON: { dependencies: { '@types/node': '^17.0.38', colors: '^1.4.0', ejs: '^3.1.8', 'ts-node': '^10.5.0' }, devDependencies: { '@types/jest': '^28.1.6', '@typescript-eslint/eslint-plugin': '^5.36.2', '@typescript-eslint/parser': '^5.36.2', eslint: '^8.23.0', 'eslint-config-prettier': '^8.5.0', 'eslint-import-resolver-node': '^0.3.6', 'eslint-plugin-import': '^2.26.0', 'eslint-plugin-jest': '^27.0.1', husky: '^8.0.1', jest: '^29.5.0', 'next-transpile-modules': '^10.0.0', prettier: '^2.7.1', 'ts-jest': '^29.1.0', 'tsconfig-paths': '^4.2.0', typescript: '^4.5.4' } }, fs: { numberOfFiles: 0 }, debug: [ '2023-05-24T23:44:06.357Z config Attempting automatic configuration for angular\n', '2023-05-24T23:44:06.362Z angular/cli config Angular CLI not found.\n', '2023-05-24T23:44:06.362Z config Finished attempting automatic configuration for angular (5ms)\n', '2023-05-24T23:44:06.363Z config Attempting automatic configuration for jest\n', "2023-05-24T23:44:06.526Z jest/config Error: Failed to read Jest configuration from '/MYREPO': Error: Jest: Failed to parse the TypeScript config file /MYREPO/jest.config.ts\n" +
" Error: Jest: 'ts-node' is required for the TypeScript configuration files. Make sure it is installed\n" +
"Error: Cannot find package 'ts-node' imported from /MYREPO/.yarn/virtual/jest-config-virtual-e1cb4122d6/0/cache/jest-config-npm-29.5.0-15ac67fe8b-c37c4dab96.zip/node_modules/jest-config/build/readConfigFileAndSetRootDir.js\n" +
'Did you mean to import ts-node-virtual-bc52ee84ce/0/cache/ts-node-npm-10.9.1-6c268be7f4-090adff130.zip/node_modules/ts-node/dist/index.js?\n' +
' at readConfigFileAndSetRootDir (/MYREPO/.yarn/virtual/jest-config-virtual-e1cb4122d6/0/cache/jest-config-npm-29.5.0-15ac67fe8b-c37c4dab96.zip/node_modules/jest-config/build/readConfigFileAndSetRootDir.js:116:13)\n' +
' at async readInitialOptions (/MYREPO/.yarn/virtual/jest-config-virtual-e1cb4122d6/0/cache/jest-config-npm-29.5.0-15ac67fe8b-c37c4dab96.zip/node_modules/jest-config/build/index.js:400:13)\n' +
' at async readConfig (/MYREPO/.yarn/virtual/jest-config-virtual-e1cb4122d6/0/cache/jest-config-npm-29.5.0-15ac67fe8b-c37c4dab96.zip/node_modules/jest-config/build/index.js:147:48)\n' +
' at async Object.readConfigs (/MYREPO/.yarn/virtual/jest-config-virtual-e1cb4122d6/0/cache/jest-config-npm-29.5.0-15ac67fe8b-c37c4dab96.zip/node_modules/jest-config/build/index.js:421:26)\n' +
' at Object. (/.vscode/extensions/wallabyjs.wallaby-vscode-1.0.355/wallabybb8894/server.js:32:2966)\n' +
' at r (/.vscode/extensions/wallabyjs.wallaby-vscode-1.0.355/wallabybb8894/server.js:31:18156)\n' +
' at Object.throw (/.vscode/extensions/wallabyjs.wallaby-vscode-1.0.355/wallabybb8894/server.js:31:17451)\n' +
' at a (/.vscode/extensions/wallabyjs.wallaby-vscode-1.0.355/wallabybb8894/server.js:31:17264)\n',
'2023-05-24T23:44:06.526Z config Finished attempting automatic configuration for jest (163ms)\n',
'2023-05-24T23:44:06.526Z config Attempting automatic configuration for vitest\n',
'2023-05-24T23:44:06.527Z vitest/config Error: Vitest dependency not found.\n' +
' at Object. (/.vscode/extensions/wallabyjs.wallaby-vscode-1.0.355/wallabybb8894/server.js:20:4286)\n' +
' at r (/.vscode/extensions/wallabyjs.wallaby-vscode-1.0.355/wallabybb8894/server.js:20:7542)\n' +
' at Object.next (/.vscode/extensions/wallabyjs.wallaby-vscode-1.0.355/wallabybb8894/server.js:20:6837)\n' +
' at /.vscode/extensions/wallabyjs.wallaby-vscode-1.0.355/wallabybb8894/server.js:20:6746\n' +
' at new Promise ()\n' +
' at n (/.vscode/extensions/wallabyjs.wallaby-vscode-1.0.355/wallabybb8894/server.js:20:6540)\n' +
' at Object.r [as configure] (/.vscode/extensions/wallabyjs.wallaby-vscode-1.0.355/wallabybb8894/server.js:20:3537)\n' +
' at Config. (/.vscode/extensions/wallabyjs.wallaby-vscode-1.0.355/wallabybb8894/server.js:15:24267)\n' +
' at r (/.vscode/extensions/wallabyjs.wallaby-vscode-1.0.355/wallabybb8894/server.js:15:15488)\n' +
' at Object.next (/.vscode/extensions/wallabyjs.wallaby-vscode-1.0.355/wallabybb8894/server.js:15:14783)\n' +
' at o (/.vscode/extensions/wallabyjs.wallaby-vscode-1.0.355/wallabybb8894/server.js:15:14532)\n',
'2023-05-24T23:44:06.527Z config Finished attempting automatic configuration for vitest (1ms)\n'
]
}