-
Notifications
You must be signed in to change notification settings - Fork 38
fix(tests): make stack frame comparison test environment-independent for Jest 30 upgrade #65
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -92,9 +92,19 @@ describe("parse", () => { | |
| testObj.testFunc(); | ||
| var parsedTrace = parse(err); | ||
|
|
||
| let comparedFrames = 0; | ||
|
|
||
| realTrace.forEach(function(real, i) { | ||
| var parsed = parsedTrace[i]; | ||
|
|
||
| // Only compare frames from our test file; deeper frames are Jest/Node | ||
| // internals whose shape varies across Node versions and environments. | ||
| const realFile = real.getFileName(); | ||
| if (!realFile || !realFile.endsWith('parse-test.js')) { | ||
| return; | ||
| } | ||
| comparedFrames++; | ||
|
|
||
| function compare(method, exceptions) { | ||
| let realValue = real[method](); | ||
| const parsedValue = parsed[method](); | ||
|
|
@@ -103,32 +113,26 @@ describe("parse", () => { | |
| realValue = exceptions[i]; | ||
| } | ||
|
|
||
| //const realJson = JSON.stringify(realValue); | ||
| //const parsedJson = JSON.stringify(parsedValue); | ||
| //console.log(method + ': ' + realJson + ' != ' + parsedJson + ' (#' + i + ')'); | ||
| expect(realValue).toBe(parsedValue); | ||
| } | ||
|
|
||
| compare('getFileName'); | ||
| compare('getFunctionName', { | ||
| 2: 'Object.asyncJestTest', | ||
| 4: 'new Promise' | ||
| }); | ||
| compare('getTypeName', { | ||
| 7: null | ||
| 1: 'Object.testFunc' | ||
| }); | ||
| compare('getTypeName'); | ||
| compare('getMethodName', { | ||
| 2: 'asyncJestTest' | ||
| }); | ||
| compare('getLineNumber', { | ||
| 0: 88, | ||
| 1: 92 | ||
| }); | ||
| compare('getColumnNumber', { | ||
| 0: 13 | ||
| 1: 'testFunc' | ||
| }); | ||
| // Line/column numbers cannot be compared: get() returns V8 CallSite | ||
| // values against babel-compiled positions, while parse() reads from the | ||
| // stack string which contains source-mapped positions. The two will | ||
| // never agree in a babel-transformed test environment. | ||
|
Comment on lines
+127
to
+130
|
||
| compare('isNative'); | ||
| }); | ||
|
|
||
| // Ensure the filter above didn't silently skip all frames. | ||
| expect(comparedFrames).toBeGreaterThan(0); | ||
| }); | ||
|
|
||
| test("stack with native call", () => { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.