-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Update jest to v24 #31825
Update jest to v24 #31825
Changes from 11 commits
a51433c
407f05f
50d304f
b720d65
6fa51a7
ceca217
4965ef2
86b04fa
ec6a293
a10c162
443a965
a220c7a
126797b
7c872e1
bdc51f4
25652e2
d15a588
1d94ac9
cf67999
b4fa793
d50fc60
a83aaf8
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 |
---|---|---|
|
@@ -12,7 +12,7 @@ exports[`#start constructs UiSettingsClient and UiSettingsApi: UiSettingsApi arg | |
], | ||
"results": Array [ | ||
Object { | ||
"isThrow": false, | ||
"type": "return", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These snapshots look like they're testing more jest internals rather than just the call arguments themselves. Can we fix these too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mocked functions are inside JS objects that serialised for snapshot testing. I didn't find a cheap way to fix it and decided to keep it as is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perfectly good reason. |
||
"value": undefined, | ||
}, | ||
], | ||
|
@@ -31,7 +31,7 @@ exports[`#start constructs UiSettingsClient and UiSettingsApi: UiSettingsClient | |
], | ||
"results": Array [ | ||
Object { | ||
"isThrow": false, | ||
"type": "return", | ||
"value": Object { | ||
"loadingCountObservable": true, | ||
}, | ||
|
@@ -52,7 +52,7 @@ exports[`#start constructs UiSettingsClient and UiSettingsApi: UiSettingsClient | |
], | ||
"results": Array [ | ||
Object { | ||
"isThrow": false, | ||
"type": "return", | ||
"value": undefined, | ||
}, | ||
], | ||
|
@@ -70,7 +70,7 @@ exports[`#start passes the uiSettings loading count to the loading count api: lo | |
], | ||
"results": Array [ | ||
Object { | ||
"isThrow": false, | ||
"type": "return", | ||
"value": undefined, | ||
}, | ||
], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ Array [ | |
], | ||
"results": Array [ | ||
Object { | ||
"isThrow": false, | ||
"type": "return", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Jest internals here as well, though this may be a bit hard to fix since it's an entire object. I'm not sure why we're testing such large snapshots like this though. |
||
"value": undefined, | ||
}, | ||
], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ let appenderMocks: Appender[]; | |
let logger: BaseLogger; | ||
|
||
const timestamp = new Date(2012, 1, 1); | ||
jest.spyOn(global, 'Date').mockImplementation(() => timestamp); | ||
jest.spyOn<any, any>(global, 'Date').mockImplementation(() => timestamp); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This spy doesn't ever seem to be restored with As an aside: it'd be awesome if there was linter rule we could add for this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 will fix. don't know why but I was sure we use |
||
|
||
beforeEach(() => { | ||
appenderMocks = [{ append: jest.fn() }, { append: jest.fn() }]; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,10 +27,10 @@ const timestamp = new Date(Date.UTC(2012, 1, 1)); | |
const mockConsoleLog = jest.spyOn(global.console, 'log').mockImplementation(() => { | ||
// noop | ||
}); | ||
jest.spyOn(global, 'Date').mockImplementation(() => timestamp); | ||
jest.spyOn<any, any>(global, 'Date').mockImplementation(() => timestamp); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above about |
||
|
||
import { createWriteStream } from 'fs'; | ||
const mockCreateWriteStream = createWriteStream as jest.Mock<typeof createWriteStream>; | ||
const mockCreateWriteStream = (createWriteStream as unknown) as jest.Mock<typeof createWriteStream>; | ||
|
||
import { LoggingConfig, LoggingService } from '.'; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,9 +40,9 @@ import { logger } from '../logging/__mocks__'; | |
const env = new Env('.', getEnvOptions()); | ||
const config$ = new BehaviorSubject({} as Config); | ||
|
||
const mockProcessExit = jest.spyOn(global.process, 'exit').mockImplementation(() => { | ||
// noop | ||
}); | ||
const mockProcessExit = jest | ||
.spyOn(global.process, 'exit') | ||
.mockImplementation(() => undefined as never); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also missing a restore. |
||
|
||
const mockConsoleError = jest.spyOn(console, 'error').mockImplementation(() => { | ||
// noop | ||
|
@@ -178,7 +178,7 @@ test('fails and stops services if initial logger upgrade fails', async () => { | |
|
||
test('stops services if consequent logger upgrade fails', async () => { | ||
const onShutdown = new BehaviorSubject<string | null>(null); | ||
const mockOnShutdown = jest.fn(() => { | ||
const mockOnShutdown = jest.fn<any, any>(() => { | ||
onShutdown.next('completed'); | ||
onShutdown.complete(); | ||
}); | ||
|
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.
question: how about updating
babel-jest
to24.1.0
here and inx-pack
?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.
babel-jest@v24
usesbabel@v7
which require@kbn/babel-preset/node_preset
update. seems like quite a bit taskThere 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.
will be done in #32326