From 2cfa76e1c34322b4f1c35a56a208774390e5cc72 Mon Sep 17 00:00:00 2001 From: Bob den Os <108393871+BobdenOs@users.noreply.github.com> Date: Wed, 17 May 2023 10:55:08 +0200 Subject: [PATCH 1/5] Update jest-runtime Include `columnOffset` property for `Script` allowing vscode to match the original file with the wrapped `Script` contents. --- packages/jest-runtime/src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/jest-runtime/src/index.ts b/packages/jest-runtime/src/index.ts index f9945f8e7f72..d44a95ac9213 100644 --- a/packages/jest-runtime/src/index.ts +++ b/packages/jest-runtime/src/index.ts @@ -1653,6 +1653,7 @@ export default class Runtime { return new Script(this.wrapCodeInModuleWrapper(scriptSource), { displayErrors: true, filename: scriptFilename, + columnOffset: this._fileTransforms.get(filename)?.wrapperLength, // @ts-expect-error: Experimental ESM API importModuleDynamically: async (specifier: string) => { invariant( From 2d3aa0ab53ac2c4976a1158dd4b3cf5efde21a17 Mon Sep 17 00:00:00 2001 From: Bob den Os <108393871+BobdenOs@users.noreply.github.com> Date: Tue, 23 May 2023 15:39:12 +0200 Subject: [PATCH 2/5] Update CHANGELOG.md Add fix description --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f6424a496c5..9d947982a870 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - `[jest-mock]` Tweak typings to allow `jest.replaceProperty()` replace methods ([#14008](https://github.com/facebook/jest/pull/14008)) - `[jest-mock]` Improve user input validation and error messages of `spyOn` and `replaceProperty` methods ([#14087](https://github.com/facebook/jest/pull/14087)) - `[jest-runtime]` Bind `jest.isolateModulesAsync` to `this` ([#14083](https://github.com/facebook/jest/pull/14083)) +- `[jest-runtime]` Forward `wrapperLength` to the `Script` constructor as `columnOffset` for accurate debugging ([#14148](https://github.com/facebook/jest/pull/14148)) - `[jest-snapshot]` Fix a potential bug when not using prettier and improve performance ([#14036](https://github.com/facebook/jest/pull/14036)) - `[@jest/transform]` Do not instrument `.json` modules ([#14048](https://github.com/facebook/jest/pull/14048)) From c9cf6960e993a6714025ea5f3ed9f2159b5a7a35 Mon Sep 17 00:00:00 2001 From: Bob den Os <108393871+BobdenOs@users.noreply.github.com> Date: Tue, 23 May 2023 15:40:51 +0200 Subject: [PATCH 3/5] Fix property order Fixes `Expected object keys to be in ascending order. 'columnOffset' should be before 'filename'` --- packages/jest-runtime/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jest-runtime/src/index.ts b/packages/jest-runtime/src/index.ts index d44a95ac9213..d59477690cb1 100644 --- a/packages/jest-runtime/src/index.ts +++ b/packages/jest-runtime/src/index.ts @@ -1651,9 +1651,9 @@ export default class Runtime { ? `jest-nodejs-core-${filename}` : filename; return new Script(this.wrapCodeInModuleWrapper(scriptSource), { + columnOffset: this._fileTransforms.get(filename)?.wrapperLength, displayErrors: true, filename: scriptFilename, - columnOffset: this._fileTransforms.get(filename)?.wrapperLength, // @ts-expect-error: Experimental ESM API importModuleDynamically: async (specifier: string) => { invariant( From 5f8ffcba4ad0f4d34faaba0da5d96568734d114c Mon Sep 17 00:00:00 2001 From: Bob den Os <108393871+BobdenOs@users.noreply.github.com> Date: Mon, 5 Jun 2023 22:39:48 +0200 Subject: [PATCH 4/5] Update globals.test.ts.snap --- e2e/__tests__/__snapshots__/globals.test.ts.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/__tests__/__snapshots__/globals.test.ts.snap b/e2e/__tests__/__snapshots__/globals.test.ts.snap index 47e0dd3db70d..5fc78e1d94f3 100644 --- a/e2e/__tests__/__snapshots__/globals.test.ts.snap +++ b/e2e/__tests__/__snapshots__/globals.test.ts.snap @@ -26,7 +26,7 @@ exports[`cannot have describe with no implementation 1`] = ` > 1 | describe('describe, no implementation'); | ^ - at Object. (__tests__/onlyConstructs.test.js:1:10)" + at Object. (__tests__/onlyConstructs.test.js:1:40)" `; exports[`cannot have describe with no implementation 2`] = ` From 5130fb5b7905549451280e860e442dc9e2af3221 Mon Sep 17 00:00:00 2001 From: Bob den Os <108393871+BobdenOs@users.noreply.github.com> Date: Mon, 5 Jun 2023 22:12:31 +0000 Subject: [PATCH 5/5] update global.test.ts.snap --- e2e/__tests__/__snapshots__/globals.test.ts.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/__tests__/__snapshots__/globals.test.ts.snap b/e2e/__tests__/__snapshots__/globals.test.ts.snap index 5fc78e1d94f3..d1ed6b3a51db 100644 --- a/e2e/__tests__/__snapshots__/globals.test.ts.snap +++ b/e2e/__tests__/__snapshots__/globals.test.ts.snap @@ -24,7 +24,7 @@ exports[`cannot have describe with no implementation 1`] = ` Missing second argument. It must be a callback function. > 1 | describe('describe, no implementation'); - | ^ + | ^ at Object. (__tests__/onlyConstructs.test.js:1:40)" `;