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
Upgrade to jest 22 #832
Upgrade to jest 22 #832
Conversation
.babelrc
Outdated
[ | ||
"transform-class-properties" | ||
"transform-builtin-extend", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed so that "XXX instanceof SubclassedError" works... Once we stop transpiling classes we can also remove this...
@@ -83,6 +83,9 @@ let requestIdleCallbackPolyfill: ( | |||
|
|||
if (typeof window === 'object' && window.requestIdleCallback) { | |||
requestIdleCallbackPolyfill = window.requestIdleCallback; | |||
} else if (typeof process === 'object' && process.nextTick) { | |||
// Node environment | |||
requestIdleCallbackPolyfill = process.nextTick; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done so that we can easily use fake timers and still have requestIdleCallback works
@@ -38,7 +40,7 @@ const kTwoWeeksInMilliseconds = 2 * 7 * 24 * 60 * 60 * 1000; | |||
* @class SymbolStoreDB | |||
* @classdesc Where does this description show up? | |||
*/ | |||
export class SymbolStoreDB { | |||
export default class SymbolStoreDB { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done so that I could mock it with jest... I couldn't find how to do with a named export :/
@@ -69,7 +69,7 @@ exports[`renders FlameGraph correctly 1`] = ` | |||
<div | |||
className="flameGraphLabels grippy" | |||
title="thread: \\"Empty\\" (0) | |||
process: \\"default\\" (0)" | |||
process: \\"default\\" (0)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like they changed how they generate snapshot for multiline string attributes
@@ -337,7 +337,18 @@ Array [ | |||
Array [ | |||
"set fillStyle", | |||
Object { | |||
"addColorStop": [Function], | |||
"addColorStop": [MockFunction] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now Jest can serialize mock functions' calls !
getSymbolTable: jest.fn().mockResolvedValue(exampleSymbolTable), | ||
})); | ||
|
||
window.TextDecoder = TextDecoder; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Various issues here, coming from the fact that we don't have indexedDB in this test file, and so SymbolStoreDB was broken. The errors weren't transmitted back to the test, but because in SymbolStore._getSymbolTable
we're storing stuff in the database but not waiting for it in the promise, the errors were "leaking" in other tests.
So I took the path of:
- Throwing back unexpected errors to the top level calls, failing the right tests
- Fixing the tests by mocking SymbolStoreDB itself, making it returning a proper value so that we don't try to store data, etc. We don't need this in this test.
This proved quite a lot of work :)
): JestMockFn<TArguments, TReturn>, | ||
mockResolvedValueOnce( | ||
value: ExtractPromiseValue<TReturn> | ||
): JestMockFn<TArguments, TReturn>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the important stuff.
This is not working as expected really, but enough for this PR I think. I fired a PR at flow-typed: flow-typed/flow-typed#1918, see comments there
// flow-typed signature: d5b32a3045854623325a334220fbc654 | ||
// flow-typed version: c7c67b81c1/jest_v20.x.x/flow_>=v0.39.x | ||
// flow-typed signature: 18018da6c1a1d95b4ab1c64bb5fe86ca | ||
// flow-typed version: c1ad61e7d4/jest_v22.x.x/flow_>=v0.39.x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too much changes in this file because of prettier, I'll revert most of the changes before landing...
Codecov Report
@@ Coverage Diff @@
## master #832 +/- ##
==========================================
+ Coverage 66.92% 67.38% +0.46%
==========================================
Files 127 128 +1
Lines 7344 5817 -1527
Branches 1670 884 -786
==========================================
- Hits 4915 3920 -995
+ Misses 2133 1632 -501
+ Partials 296 265 -31
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanations. I don't know very much about all this, but what you say makes sense and the changes look non-controversial.
Nice @julienw |
There are some test failures. |
This is weird, these test failures look like something I fixed... |
Ah, this is fun, the error happens only with |
Especially this introduces a specialized Error for symbolication, so that we can distinguish errors and more easily debug tests by rethrowing unexpected errors.
My theory is that when collecting coverage some more instrumentation is added to the files and as a result the babel transform doesn't work anymore. I removed the transforms, and instead I manually added a line to the constructor: constructor(message: string, library: Library, error?: Error) {
super(message);
// Workaround for a babel issue when extending Errors
(this: any).__proto__ = SymbolsNotFoundError.prototype;
this.name = 'SymbolsNotFoundError';
this.library = library;
this.error = error;
} Other alternatives:
|
No description provided.