Skip to content

Commit

Permalink
Bump jest related packages (#58095)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrykkopycinski authored Jun 20, 2020
1 parent 73af840 commit cc4c172
Show file tree
Hide file tree
Showing 184 changed files with 2,721 additions and 2,165 deletions.
15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
"reselect": "^4.0.0",
"resize-observer-polyfill": "^1.5.0",
"rison-node": "1.0.2",
"rxjs": "^6.5.3",
"rxjs": "^6.5.5",
"script-loader": "0.7.2",
"seedrandom": "^3.0.5",
"semver": "^5.5.0",
Expand Down Expand Up @@ -346,7 +346,7 @@
"@types/history": "^4.7.3",
"@types/hoek": "^4.1.3",
"@types/inert": "^5.1.2",
"@types/jest": "24.0.19",
"@types/jest": "^25.2.3",
"@types/joi": "^13.4.2",
"@types/jquery": "^3.3.31",
"@types/js-yaml": "^3.11.1",
Expand Down Expand Up @@ -391,6 +391,7 @@
"@types/supertest-as-promised": "^2.0.38",
"@types/tar": "^4.0.3",
"@types/testing-library__dom": "^6.10.0",
"@types/testing-library__jest-dom": "^5.7.0",
"@types/testing-library__react": "^9.1.2",
"@types/testing-library__react-hooks": "^3.1.0",
"@types/type-detect": "^4.0.1",
Expand All @@ -403,7 +404,7 @@
"archiver": "^3.1.1",
"axe-core": "^3.4.1",
"babel-eslint": "^10.0.3",
"babel-jest": "^24.9.0",
"babel-jest": "^25.5.1",
"babel-plugin-istanbul": "^6.0.0",
"backport": "5.4.1",
"chai": "3.5.0",
Expand All @@ -423,7 +424,7 @@
"eslint-plugin-ban": "^1.4.0",
"eslint-plugin-cypress": "^2.8.1",
"eslint-plugin-import": "^2.19.1",
"eslint-plugin-jest": "^23.3.0",
"eslint-plugin-jest": "^23.10.0",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-mocha": "^6.2.2",
"eslint-plugin-no-unsanitized": "^3.0.2",
Expand Down Expand Up @@ -452,8 +453,10 @@
"intl-messageformat-parser": "^1.4.0",
"is-path-inside": "^2.1.0",
"istanbul-instrumenter-loader": "3.0.1",
"jest": "^24.9.0",
"jest-cli": "^24.9.0",
"jest": "^25.5.4",
"jest-environment-jsdom-thirteen": "^1.0.1",
"jest-circus": "^25.5.4",
"jest-cli": "^25.5.4",
"jest-raw-loader": "^1.0.1",
"jimp": "^0.9.6",
"json5": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config-kibana/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"eslint-plugin-ban": "^1.4.0",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-import": "^2.19.1",
"eslint-plugin-jest": "^23.3.0",
"eslint-plugin-jest": "^23.10.0",
"eslint-plugin-mocha": "^6.2.2",
"eslint-plugin-no-unsanitized": "^3.0.2",
"eslint-plugin-prefer-object-spread": "^1.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"getopts": "^2.2.5",
"load-json-file": "^6.2.0",
"moment": "^2.24.0",
"rxjs": "^6.5.3",
"rxjs": "^6.5.5",
"tree-kill": "^1.2.2",
"tslib": "^2.0.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { REPO_ROOT } from '../repo_root';

export function createAbsolutePathSerializer(rootPath: string = REPO_ROOT) {
return {
print: (value: string) => value.replace(rootPath, '<absolute path>').replace(/\\/g, '/'),
serialize: (value: string) => value.replace(rootPath, '<absolute path>').replace(/\\/g, '/'),
test: (value: any) => typeof value === 'string' && value.startsWith(rootPath),
};
}
4 changes: 2 additions & 2 deletions packages/kbn-optimizer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
"execa": "^4.0.2",
"file-loader": "^4.2.0",
"istanbul-instrumenter-loader": "^3.0.1",
"jest-diff": "^25.1.0",
"jest-diff": "^25.5.0",
"json-stable-stringify": "^1.0.1",
"loader-utils": "^1.2.3",
"node-sass": "^4.13.0",
"normalize-path": "^3.0.0",
"postcss-loader": "^3.0.0",
"raw-loader": "^3.1.0",
"resolve-url-loader": "^3.1.1",
"rxjs": "^6.5.3",
"rxjs": "^6.5.5",
"sass-loader": "^8.0.2",
"style-loader": "^1.1.3",
"terser-webpack-plugin": "^2.1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const MOCK_REPO_SRC = Path.resolve(__dirname, '../__fixtures__/mock_repo');
const MOCK_REPO_DIR = Path.resolve(TMP_DIR, 'mock_repo');

expect.addSnapshotSerializer({
print: (value: string) => value.split(REPO_ROOT).join('<absolute path>').replace(/\\/g, '/'),
serialize: (value: string) => value.split(REPO_ROOT).join('<absolute path>').replace(/\\/g, '/'),
test: (value: any) => typeof value === 'string' && value.includes(REPO_ROOT),
});

Expand Down
123 changes: 77 additions & 46 deletions packages/kbn-pm/dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/kbn-pm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"ora": "^1.4.0",
"prettier": "^2.0.5",
"read-pkg": "^5.2.0",
"rxjs": "^6.5.3",
"rxjs": "^6.5.5",
"spawn-sync": "^1.0.15",
"string-replace-loader": "^2.2.0",
"strip-ansi": "^4.0.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/kbn-pm/src/commands/bootstrap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ test('handles dependencies of dependencies', async () => {
expect(mockInstallInDir.mock.calls).toMatchSnapshot('install in dir');
expect(logWriter.messages).toMatchInlineSnapshot(`
Array [
" info [kibana] running yarn",
info [kibana] running yarn,
"",
"",
" info [bar] running yarn",
info [bar] running yarn,
"",
"",
" info [foo] running yarn",
info [foo] running yarn,
"",
"",
]
Expand Down Expand Up @@ -174,7 +174,7 @@ test('does not run installer if no deps in package', async () => {
expect(mockInstallInDir.mock.calls).toMatchSnapshot('install in dir');
expect(logWriter.messages).toMatchInlineSnapshot(`
Array [
" info [kibana] running yarn",
info [kibana] running yarn,
"",
"",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import hasAnsi from 'has-ansi';
import stripAnsi from 'strip-ansi';

export const stripAnsiSnapshotSerializer = {
print(value: string, serialize: (val: string) => string) {
return serialize(stripAnsi(value));
export const stripAnsiSnapshotSerializer: jest.SnapshotSerializerPlugin = {
serialize(value: string) {
return stripAnsi(value);
},

test(value: any) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/kbn-pm/src/utils/link_project_executables.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ describe('bin script points to a file', () => {
expect(getFsMockCalls()).toMatchSnapshot('fs module calls');
expect(logWriter.messages).toMatchInlineSnapshot(`
Array [
" debg Linking package executables",
" debg [foo] bar -> ../bar/bin/bar.js",
" debg [baz] bar -> ../bar/bin/bar.js",
debg Linking package executables,
debg [foo] bar -> ../bar/bin/bar.js,
debg [baz] bar -> ../bar/bin/bar.js,
]
`);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-spec-to-console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"homepage": "https://github.com/jbudz/spec-to-console#readme",
"devDependencies": {
"jest": "^24.9.0",
"jest": "^25.5.4",
"prettier": "^2.0.5"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"mini-css-extract-plugin": "0.7.0",
"normalize-path": "3.0.0",
"react-docgen-typescript-loader": "3.1.0",
"rxjs": "6.5.2",
"rxjs": "6.5.5",
"serve-static": "1.14.1",
"styled-components": "^5.1.0",
"webpack": "^4.41.5"
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"joi": "^13.5.2",
"parse-link-header": "^1.0.1",
"puppeteer": "^3.3.0",
"rxjs": "^6.5.3",
"rxjs": "^6.5.5",
"strip-ansi": "^5.2.0",
"tar-fs": "^1.16.3",
"tmp": "^0.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { createPatch } from 'diff';
// turns out Jest can't encode xml diffs in their JUnit reports...
expect.addSnapshotSerializer({
test: (v) => typeof v === 'string' && (v.includes('<') || v.includes('>')),
print: (v) => v.replace(/</g, '‹').replace(/>/g, '›').replace(/^\s+$/gm, ''),
serialize: (v) => v.replace(/</g, '‹').replace(/>/g, '›').replace(/^\s+$/gm, ''),
});

jest.mock('fs', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,34 @@ describe('KuiTextInput', () => {
});

describe('autoFocus', () => {
/* eslint-disable no-console */
// Silence until enzyme fixed https://github.com/enzymejs/enzyme/issues/2337
const originalError = console.error;
beforeAll(() => {
console.error = jest.fn();
});
afterAll(() => {
console.error = originalError;
});
/* eslint-enable no-console */

test('sets focus on the element', () => {
const component = mount(
<KuiTextInput autoFocus onChange={() => {}} data-test-subj="input" />
<KuiTextInput autoFocus={true} onChange={() => {}} data-test-subj="input" />,
{ attachTo: document.body }
);

expect(findTestSubject(component, 'input').getDOMNode()).toBe(document.activeElement);
component.unmount();
});

test('does not focus the element by default', () => {
const component = mount(<KuiTextInput onChange={() => {}} data-test-subj="input" />);
const component = mount(<KuiTextInput onChange={() => {}} data-test-subj="input" />, {
attachTo: document.body,
});

expect(findTestSubject(component, 'input').getDOMNode()).not.toBe(document.activeElement);
component.unmount();
});
});

Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-ui-shared-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"react-router": "^5.1.2",
"react-router-dom": "^5.1.2",
"regenerator-runtime": "^0.13.3",
"rxjs": "^6.5.3",
"rxjs": "^6.5.5",
"symbol-observable": "^1.2.0",
"whatwg-fetch": "^3.0.0"
},
Expand Down
12 changes: 8 additions & 4 deletions src/core/public/application/application_service.test.mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ jest.doMock('history', () => ({
}));

export const parseAppUrlMock = jest.fn();
jest.doMock('./utils', () => ({
...jest.requireActual('./utils'),
parseAppUrl: parseAppUrlMock,
}));
jest.doMock('./utils', () => {
const original = jest.requireActual('./utils');

return {
...original,
parseAppUrl: parseAppUrlMock,
};
});
Original file line number Diff line number Diff line change
Expand Up @@ -147,44 +147,52 @@ describe('ApplicationService', () => {
});
});

it('redirects to full path when navigating to legacy app', async () => {
const redirectTo = jest.fn();
const reloadSpy = jest.spyOn(window.location, 'reload').mockImplementation(() => {});

// In the real application, we use a BrowserHistory instance configured with `basename`. However, in tests we must
// use MemoryHistory which does not support `basename`. In order to emulate this behavior, we will wrap this
// instance with a ScopedHistory configured with a basepath.
history.push(setupDeps.http.basePath.get()); // ScopedHistory constructor will fail if underlying history is not currently at basePath.
const { register, registerLegacyApp } = service.setup({
...setupDeps,
redirectTo,
history: new ScopedHistory(history, setupDeps.http.basePath.get()),
describe('redirects', () => {
beforeAll(() => {
Object.defineProperty(window, 'location', {
value: {
reload: jest.fn(),
},
});
});

register(Symbol(), {
id: 'app1',
title: 'App1',
mount: ({ onAppLeave }: AppMountParameters) => {
onAppLeave((actions) => actions.default());
return () => undefined;
},
});
registerLegacyApp({
id: 'myLegacyTestApp',
appUrl: '/app/myLegacyTestApp',
title: 'My Legacy Test App',
});
it('to full path when navigating to legacy app', async () => {
const redirectTo = jest.fn();

// In the real application, we use a BrowserHistory instance configured with `basename`. However, in tests we must
// use MemoryHistory which does not support `basename`. In order to emulate this behavior, we will wrap this
// instance with a ScopedHistory configured with a basepath.
history.push(setupDeps.http.basePath.get()); // ScopedHistory constructor will fail if underlying history is not currently at basePath.
const { register, registerLegacyApp } = service.setup({
...setupDeps,
redirectTo,
history: new ScopedHistory(history, setupDeps.http.basePath.get()),
});

register(Symbol(), {
id: 'app1',
title: 'App1',
mount: ({ onAppLeave }: AppMountParameters) => {
onAppLeave((actions) => actions.default());
return () => undefined;
},
});
registerLegacyApp({
id: 'myLegacyTestApp',
appUrl: '/app/myLegacyTestApp',
title: 'My Legacy Test App',
});

const { navigateToApp, getComponent } = await service.start(startDeps);
const { navigateToApp, getComponent } = await service.start(startDeps);

update = createRenderer(getComponent());
update = createRenderer(getComponent());

await navigate('/test/app/app1');
await act(() => navigateToApp('myLegacyTestApp', { path: '#/some-path' }));
await navigate('/test/app/app1');
await act(() => navigateToApp('myLegacyTestApp', { path: '#/some-path' }));

expect(redirectTo).toHaveBeenCalledWith('/test/app/myLegacyTestApp#/some-path');
expect(reloadSpy).toHaveBeenCalled();
reloadSpy.mockRestore();
expect(redirectTo).toHaveBeenCalledWith('/test/app/myLegacyTestApp#/some-path');
expect(window.location.reload).toHaveBeenCalled();
});
});

describe('leaving an application that registered an app leave handler', () => {
Expand Down
Loading

0 comments on commit cc4c172

Please sign in to comment.