firsttris / vscode-jest-runner

Simple way to run or debug one or more tests from context menu, codelens or command plalette
https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner
MIT License
265 stars 124 forks source link

Update jest-editor-support, fix CI #239

Closed nirgilboa closed 2 years ago

nirgilboa commented 2 years ago

Changes included:

  1. Upgrade jest-editor-support to fix Typescript compilation errors
  2. Add a test-compile step to GitHub Workflow
  3. Use MacOS for GitHub Workflow (which runs headless tests oob)

Currently still facing the following error when running the tests, seems to be caused by: https://github.com/facebook/jest/issues/12398

TypeError: Cannot assign to read only property 'write' of object '#<Socket>'
    at DefaultReporter.__wrapStdio (/Users/runner/work/vscode-jest-runner/vscode-jest-runner/node_modules/@jest/reporters/build/DefaultReporter.js:139:18)
    at new DefaultReporter (/Users/runner/work/vscode-jest-runner/vscode-jest-runner/node_modules/@jest/reporters/build/DefaultReporter.js:90:10)
    at TestScheduler._setupDefaultReporters (/Users/runner/work/vscode-jest-runner/vscode-jest-runner/node_modules/@jest/core/build/TestScheduler.js:[45](https://github.com/firsttris/vscode-jest-runner/runs/5346425815?check_suite_focus=true#step:7:45)6:11)
    at TestScheduler._setupReporters (/Users/runner/work/vscode-jest-runner/vscode-jest-runner/node_modules/@jest/core/build/TestScheduler.js:415:12)
    at createTestScheduler (/Users/runner/work/vscode-jest-runner/vscode-jest-runner/node_modules/@jest/core/build/TestScheduler.js:114:19)
    at runJest (/Users/runner/work/vscode-jest-runner/vscode-jest-runner/node_modules/@jest/core/build/runJest.js:397:66)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async _run10000 (/Users/runner/work/vscode-jest-runner/vscode-jest-runner/node_modules/@jest/core/build/cli/index.js:320:7)
    at async runCLI (/Users/runner/work/vscode-jest-runner/vscode-jest-runner/node_modules/@jest/core/build/cli/index.js:173:3)
F3n67u commented 2 years ago

It's fixed by vscode team, see https://github.com/microsoft/vscode/commit/6f0c1b068a84ddf1c06cac054873ac7a8b5ff3ba

nirgilboa commented 2 years ago

It's fixed by vscode team, see microsoft/vscode@6f0c1b0

Thanks for this! 🙏🏻 will wait for a new vscode version

Cellule commented 2 years ago

When running npm run compile I get the following errors (trying to pack README.md and LICENSE files)

ERROR in ./node_modules/@babel/plugin-syntax-typescript/test/index.js 1:0-54
Module not found: Error: Can't resolve '@babel/helper-plugin-test-runner' in 'C:\projects\vscode-jest-runner\node_modules\@babel\plugin-syntax-typescript\test'
 @ ./node_modules/@babel/ sync ^\.\/plugin\-syntax\-.*$ ./plugin-syntax-typescript/test/index.js ./plugin-syntax-typescript/test/index ./plugin-syntax-typescript/test/ ./plugin-syntax-typescript/test
 @ ./node_modules/babel-preset-current-node-syntax/src/index.js 39:17-64
 @ ./node_modules/jest-snapshot/build/InlineSnapshots.js 203:19-70
 @ ./node_modules/jest-snapshot/build/State.js 27:23-51
 @ ./node_modules/jest-snapshot/build/index.js 9:36-54
 @ ./node_modules/jest-editor-support/build/Snapshot.js 34:20-44
 @ ./node_modules/jest-editor-support/build/index.js 130:39-60
 @ ./src/jestRunner.ts 13:30-60
 @ ./src/extension.ts 14:21-44

Which seems to come from https://github.com/nicolo-ribaudo/babel-preset-current-node-syntax/blob/93b2088940fd53adb7c4774d406176885443082f/src/index.js#L37-L41

But it doesn't look like that module changed, so not sure why I'm getting this error now

Cellule commented 2 years ago

I think this extension packs wayyy too much of jest-editor-support when it only needs the parser I made a new parser.ts file that only imports the parser and the build is much faster, avoids all these other issues and resulting extension file is much smaller (1.22MiB vs 5.43MiB in development)

// parser.ts
import type { ParsedNode } from 'jest-editor-support';
import parse from 'jest-editor-support/build/parsers';

export { parse, ParsedNode };

then all imports to jest-editor-support is replaced by ./parser

nirgilboa commented 2 years ago

then all imports to jest-editor-support is replaced by ./parser

Awesome !! 💪🏻 If you don't mind I think fixing the CI should be merged first (once a new vscode version is released) and then merge your PR

Cellule commented 2 years ago

All good! I agree should fix CI first. I made the change because I wasn't able to test the update otherwise and I wanted to confirm it fixed a parsing issue related to recent typescript language features, which it does 😁

nirgilboa commented 2 years ago

@firsttris Build is now green 🎉 as it runs with vscode 1.65.0 which contains the bugfix we needed (https://github.com/microsoft/vscode/releases/tag/1.65.0)