Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve source map handling when instrumenting transformed code (#5739) #9811

Merged
merged 15 commits into from Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,27 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`processes stack traces and code frames with source maps with coverage 1`] = `
Object {
"rest": "FAIL __tests__/fails.ts
✕ fails

● fails

This did not work!

11 |
12 | export function error() {
> 13 | throw new Error('This did not work!');
| ^
14 | }
15 |

at Object.error (lib.ts:13:9)
at Object.<anonymous> (__tests__/fails.ts:10:3)",
"summary": "Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: <<REPLACED>>
Ran all test suites.",
}
`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For posterity (if we ever come back to this and wonder why we pass sourcemap into Babel), this is the error if running this test without the other changes in this PR

image

8 changes: 2 additions & 6 deletions e2e/__tests__/stackTraceSourceMapsWithCoverage.test.ts
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import * as path from 'path';
import {run} from '../Utils';
import {extractSummary, run} from '../Utils';
import runJest from '../runJest';

it('processes stack traces and code frames with source maps with coverage', () => {
Expand All @@ -15,9 +15,5 @@ it('processes stack traces and code frames with source maps with coverage', () =
);
run('yarn', dir);
const {stderr} = runJest(dir, ['--no-cache', '--coverage']);

// Should report an error at source line 13 in lib.ts at line 10 of the test
SimenB marked this conversation as resolved.
Show resolved Hide resolved
expect(stderr).toMatch("13 | throw new Error('This did not work!');\n");
expect(stderr).toMatch(`at Object.error (lib.ts:13:9)
at Object.<anonymous> (__tests__/fails.ts:10:3)`);
expect(extractSummary(stderr)).toMatchSnapshot();
SimenB marked this conversation as resolved.
Show resolved Hide resolved
});
1 change: 0 additions & 1 deletion packages/jest-runtime/src/index.ts
Expand Up @@ -140,7 +140,6 @@ class Runtime {
private _isolatedModuleRegistry: ModuleRegistry | null;
private _moduleRegistry: ModuleRegistry;
private _esmoduleRegistry: Map<string, Promise<VMModule>>;
private _needsCoverageMapped: Set<string>;
private _resolver: Resolver;
private _shouldAutoMock: boolean;
private _shouldMockModuleCache: BooleanObject;
Expand Down