vscode-firefox-debug icon indicating copy to clipboard operation
vscode-firefox-debug copied to clipboard

Fix webpack sourcemap tests

Open hbenl opened this issue 1 year ago • 3 comments

Most of the tests that verify sourcemap support for webpack bundles have been broken for a while, this PR fixes them.

hbenl avatar Mar 10 '24 10:03 hbenl

So I ran npm run test src/test/testWebpackSourceMaps.ts and I'm still seeing errors:

145 passing (3m)
  8 pending
  6 failing

  1) Webpack sourcemaps: The debugger
       should map webpack-bundled modules with devtool "cheap-eval-source-map" to their original sources:
     ValidationError: Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
 - configuration.devtool should match pattern "^(inline-|hidden-|eval-)?(nosources-)?(cheap-(module-)?)?source-map$".
   BREAKING CHANGE since webpack 5: The devtool option is more strict.
   Please strictly follow the order of the keywords in the pattern.
      at validate (node_modules/webpack/node_modules/schema-utils/dist/validate.js:191:11)
      at validateSchema (node_modules/webpack/lib/validateSchema.js:78:2)
      at create (node_modules/webpack/lib/webpack.js:119:24)
      at webpack (node_modules/webpack/lib/webpack.js:151:47)
      at f (node_modules/webpack/lib/index.js:72:16)
      at /Users/nchevobbe/Projects/vscode-firefox-debug/src/test/testWebpackSourceMaps.ts:85:10
      at new Promise (<anonymous>)
      at build (src/test/testWebpackSourceMaps.ts:84:9)
      at Context.<anonymous> (src/test/testWebpackSourceMaps.ts:46:10)
      at Generator.next (<anonymous>)
      at fulfilled (src/test/testWebpackSourceMaps.ts:28:58)

  2) Webpack sourcemaps: The debugger
       should map webpack-bundled modules with devtool "cheap-module-eval-source-map" to their original sources:
     ValidationError: Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
 - configuration.devtool should match pattern "^(inline-|hidden-|eval-)?(nosources-)?(cheap-(module-)?)?source-map$".
   BREAKING CHANGE since webpack 5: The devtool option is more strict.
   Please strictly follow the order of the keywords in the pattern.
      at validate (node_modules/webpack/node_modules/schema-utils/dist/validate.js:191:11)
      at validateSchema (node_modules/webpack/lib/validateSchema.js:78:2)
      at create (node_modules/webpack/lib/webpack.js:119:24)
      at webpack (node_modules/webpack/lib/webpack.js:151:47)
      at f (node_modules/webpack/lib/index.js:72:16)
      at /Users/nchevobbe/Projects/vscode-firefox-debug/src/test/testWebpackSourceMaps.ts:85:10
      at new Promise (<anonymous>)
      at build (src/test/testWebpackSourceMaps.ts:84:9)
      at Context.<anonymous> (src/test/testWebpackSourceMaps.ts:46:10)
      at Generator.next (<anonymous>)
      at fulfilled (src/test/testWebpackSourceMaps.ts:28:58)

  3) Webpack sourcemaps: The debugger
       should map webpack-bundled modules with devtool "eval-source-map" to their original sources:

      AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
+ actual - expected

+ []
- [
-   {
-     column: 1,
-     line: 7
-   },
-   {
-     column: 6,
-     line: 7
-   }
- ]
      + expected - actual

      -[]
      +[
      +  {
      +    "column": 1
      +    "line": 7
      +  }
      +  {
      +    "column": 6
      +    "line": 7
      +  }
      +]
      
      at Context.<anonymous> (src/test/testWebpackSourceMaps.ts:59:12)
      at Generator.next (<anonymous>)
      at fulfilled (src/test/testWebpackSourceMaps.ts:28:58)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)

  4) The configuration parser
       should not allow "reAttach" to be false while "keepProfileChanges" is true on MacOS:
     Error: This configuration should have been rejected
      at Context.<anonymous> (src/test/testConfigurationParser.ts:328:9)
      at Generator.next (<anonymous>)
      at fulfilled (src/test/testConfigurationParser.ts:28:58)

  5) The configuration parser
       should copy "profileDir" to "profileDir" if "keepProfileChanges" is true:
     Error: the string "On MacOS, \"keepProfileChanges\" is only allowed with \"reAttach\" because your profile may get damaged otherwise" was thrown, throw an Error :)
  

  6) Data breakpoints: The debug adapter
       "after each" hook for "should add a data breakpoint and hit it":
     TypeError: Cannot read properties of undefined (reading 'stop')
      at Context.<anonymous> (src/test/testDataBreakpoints.ts:13:12)
      at Generator.next (<anonymous>)
      at /Users/nchevobbe/Projects/vscode-firefox-debug/src/test/testDataBreakpoints.ts:31:71
      at new Promise (<anonymous>)
      at __awaiter (src/test/testDataBreakpoints.ts:27:12)
      at Context.<anonymous> (src/test/testDataBreakpoints.ts:42:16)
      at processImmediate (node:internal/timers:478:21)

is this expected?

nchevobbe avatar Mar 18 '24 13:03 nchevobbe

So I ran npm run test src/test/testWebpackSourceMaps.ts and I'm still seeing errors: is this expected?

so I actually forgot to checkout the PR's branch, but now, I'm getting even more failure, so I'm questioning if I'm running them properly?

nchevobbe avatar Mar 18 '24 14:03 nchevobbe

So I ran npm run test src/test/testWebpackSourceMaps.ts and I'm still seeing errors:

That's not expected, some of the failures seem mac-specific, I'll have a look at them later.

now, I'm getting even more failure, so I'm questioning if I'm running them properly?

~npm run test should work. Adding an argument to restrict which tests should run doesn't work though.~ I usually use a VS Code extension to run them: https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-mocha-test-adapter Also it sometimes happened to me that one of the Firefox processes started for the tests is not terminated and then all subsequent tests fail because the debugger port is blocked.

Edit: just saw your message that npm run test doesn't work. I'll fix that later.

hbenl avatar Mar 18 '24 15:03 hbenl

I've fixed the tests on MacOS:

  • 2 configuration parser tests were broken by #224
  • the webpack sourcemap tests were broken because on MacOS os.tmpdir() returns a path containing a symlink, which confused webpack

I have also made some further updates to the test setup:

  • run the tests using tsx instead of ts-node (because it's faster)
  • consolidate the mocha configuration (ensuring that we get the same results on the command line and in the Test Explorer)
  • remove an old environment variable that was used for running the tests against Firefox <70
  • add an extension recommendation for the Mocha Test Explorer

To run the tests you may have to add FIREFOX_EXECUTABLE=stable to src/test/.env because the adapter doesn't work with the latest developer edition (see #360, I'll look into this soon)

hbenl avatar Mar 24 '24 17:03 hbenl

The changes look good to me, but I must be doing something wrong, I get Could not establish connection. Receiving end does not exist, from receivePageLoadedEvent

nchevobbe avatar Mar 25 '24 14:03 nchevobbe

Hmm, I've never seen that error. Did you rebuild before trying to run the tests? Also I noticed that on MacOS it seems to happen more often that the Firefox instance started for a test does not get terminated. Try commenting out HEADLESS=true in src/test/.env so that you can close these instances manually if necessary.

hbenl avatar Mar 25 '24 18:03 hbenl

Hmm, I've never seen that error. Did you rebuild before trying to run the tests?

yes I did

Also I noticed that on MacOS it seems to happen more often that the Firefox instance started for a test does not get terminated. Try commenting out HEADLESS=true in src/test/.env so that you can close these instances manually if necessary.

indeed, I was able to see that yesterday, the instance are kept alive for some reason. Let's go ahead with the patch since this works for you, and I'll try to figure out what's the issue with my setup

nchevobbe avatar Mar 26 '24 09:03 nchevobbe