Revert "Update Jest and jsdom (#11037)"
This reverts commit 1e2fc74dbd
.
This commit is contained in:
Родитель
1e2fc74dbd
Коммит
6612335ab7
|
@ -24,7 +24,6 @@ module.exports = {
|
|||
'<rootDir>/tests/jest-reporters/eslint-check.js',
|
||||
],
|
||||
setupFilesAfterEnv: ['<rootDir>/tests/setup.js'],
|
||||
testEnvironment: 'jsdom',
|
||||
testPathIgnorePatterns: [
|
||||
'<rootDir>/node_modules/',
|
||||
'<rootDir>/(assets|bin|config|coverage|dist|docs|flow|locale|src)/',
|
||||
|
|
|
@ -188,7 +188,7 @@
|
|||
"isomorphic-fetch": "3.0.0",
|
||||
"jed": "1.1.1",
|
||||
"join-url": "2.0.0",
|
||||
"jsdom": "19.0.0",
|
||||
"jsdom": "16.7.0",
|
||||
"localforage": "1.10.0",
|
||||
"lodash.debounce": "4.0.8",
|
||||
"moment": "2.29.1",
|
||||
|
@ -249,7 +249,7 @@
|
|||
"autoprefixer": "^10.2.4",
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"babel-gettext-extractor": "^4.1.3",
|
||||
"babel-jest": "^27.0.0",
|
||||
"babel-jest": "^26.0.0",
|
||||
"babel-loader": "^8.0.4",
|
||||
"babel-plugin-dynamic-import-node": "^2.2.0",
|
||||
"bundle-loader": "^0.5.5",
|
||||
|
@ -280,7 +280,7 @@
|
|||
"husky": "^7.0.0",
|
||||
"intl": "^1.2.5",
|
||||
"intl-locales-supported": "^1.0.0",
|
||||
"jest": "^27.0.0",
|
||||
"jest": "^26.0.0",
|
||||
"jest-enzyme": "^7.0.0",
|
||||
"jest-watch-typeahead": "^0.6.1",
|
||||
"lint-staged": "^12.0.0",
|
||||
|
|
|
@ -1,21 +1,12 @@
|
|||
/* global window */
|
||||
import { JSDOM } from 'jsdom';
|
||||
|
||||
// We need a window from jsdom when it does not exist, which is when we are
|
||||
// running on node (for SSR). 'amo/window' provides this for us, by importing
|
||||
// jsdom, but we don't want to import that in tests, as the tests already
|
||||
// import jsdom via the "jsdom" testEnvironment.
|
||||
let jsDomDocument;
|
||||
if (typeof window === 'undefined') {
|
||||
// eslint-disable-next-line global-require
|
||||
const { JSDOM } = require('jsdom');
|
||||
jsDomDocument = new JSDOM('', {
|
||||
features: {
|
||||
// disables resource loading over HTTP / filesystem
|
||||
FetchExternalResources: false,
|
||||
// do not execute JS within script blocks
|
||||
ProcessExternalResources: false,
|
||||
},
|
||||
});
|
||||
}
|
||||
const jsDomDocument = new JSDOM('', {
|
||||
features: {
|
||||
// disables resource loading over HTTP / filesystem
|
||||
FetchExternalResources: false,
|
||||
// do not execute JS within script blocks
|
||||
ProcessExternalResources: false,
|
||||
},
|
||||
});
|
||||
|
||||
export default (jsDomDocument && jsDomDocument.window) || window;
|
||||
export default jsDomDocument.window;
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
/* eslint import/no-extraneous-dependencies: 0 */
|
||||
const chalk = require('chalk');
|
||||
const { getConsoleOutput } = require('@jest/console');
|
||||
const { DefaultReporter } = require('@jest/reporters');
|
||||
const { utils } = require('@jest/reporters');
|
||||
const DefaultReporter =
|
||||
require('@jest/reporters/build/DefaultReporter').default;
|
||||
const getResultHeader =
|
||||
require('@jest/reporters/build/getResultHeader').default;
|
||||
|
||||
const TITLE_BULLET = chalk.bold('\u25cf ');
|
||||
|
||||
|
@ -10,7 +12,7 @@ const TITLE_BULLET = chalk.bold('\u25cf ');
|
|||
// failing, see: https://github.com/mozilla/addons-frontend/issues/2980.
|
||||
class FingersCrossedReporter extends DefaultReporter {
|
||||
printTestFileHeader(testPath, config, result) {
|
||||
this.log(utils.getResultHeader(result, this._globalConfig, config));
|
||||
this.log(getResultHeader(result, this._globalConfig, config));
|
||||
|
||||
const consoleBuffer = result.console;
|
||||
const testFailed = result.numFailingTests > 0;
|
||||
|
@ -19,9 +21,9 @@ class FingersCrossedReporter extends DefaultReporter {
|
|||
// prettier-ignore
|
||||
this.log(
|
||||
` ${TITLE_BULLET}Console\n\n${getConsoleOutput(
|
||||
consoleBuffer,
|
||||
config,
|
||||
this._globalConfig,
|
||||
config.cwd,
|
||||
!!this._globalConfig.verbose,
|
||||
consoleBuffer
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint import/no-extraneous-dependencies: 0 */
|
||||
const { SummaryReporter } = require('@jest/reporters');
|
||||
const SummaryReporter =
|
||||
require('@jest/reporters/build/SummaryReporter').default;
|
||||
|
||||
module.exports = SummaryReporter;
|
||||
|
|
|
@ -309,10 +309,7 @@ describe(__filename, () => {
|
|||
it('does not prefix a non-custom license link to point to AMO', () => {
|
||||
// See: https://github.com/mozilla/addons-frontend/issues/3339
|
||||
_loadVersions({
|
||||
license: {
|
||||
name: createLocalizedString('tofulicense'),
|
||||
url: 'www.license.com/',
|
||||
},
|
||||
license: { name: 'tofulicense', url: 'www.license.com/' },
|
||||
});
|
||||
const root = render();
|
||||
const link = root.find('.AddonMoreInfo-license-link');
|
||||
|
@ -816,7 +813,7 @@ describe(__filename, () => {
|
|||
_loadVersions({
|
||||
license: {
|
||||
is_custom: true,
|
||||
name: createLocalizedString('tofulicense'),
|
||||
name: 'tofulicense',
|
||||
url: 'www.license.com',
|
||||
},
|
||||
});
|
||||
|
|
|
@ -130,7 +130,7 @@ describe(__filename, () => {
|
|||
const root = render({
|
||||
addon: createInternalAddonWithLang({
|
||||
...fakeAddon,
|
||||
name: createLocalizedString('<script>alert(document.cookie);</script>'),
|
||||
name: '<script>alert(document.cookie);</script>',
|
||||
authors: [],
|
||||
}),
|
||||
});
|
||||
|
|
|
@ -7,11 +7,7 @@ import SearchResult from 'amo/components/SearchResult';
|
|||
import { DEFAULT_API_PAGE_SIZE } from 'amo/api';
|
||||
import { ADDON_TYPE_STATIC_THEME } from 'amo/constants';
|
||||
import CardList from 'amo/components/CardList';
|
||||
import {
|
||||
createInternalAddonWithLang,
|
||||
createLocalizedString,
|
||||
fakeAddon,
|
||||
} from 'tests/unit/helpers';
|
||||
import { createInternalAddonWithLang, fakeAddon } from 'tests/unit/helpers';
|
||||
|
||||
describe(__filename, () => {
|
||||
let addons;
|
||||
|
@ -28,16 +24,8 @@ describe(__filename, () => {
|
|||
|
||||
beforeAll(() => {
|
||||
addons = [
|
||||
{
|
||||
...fakeAddon,
|
||||
name: createLocalizedString('I am add-on! '),
|
||||
slug: 'i-am-addon',
|
||||
},
|
||||
{
|
||||
...fakeAddon,
|
||||
name: createLocalizedString('I am also add-on!'),
|
||||
slug: 'i-am-also-addon',
|
||||
},
|
||||
{ ...fakeAddon, name: 'I am add-on! ', slug: 'i-am-addon' },
|
||||
{ ...fakeAddon, name: 'I am also add-on!', slug: 'i-am-also-addon' },
|
||||
];
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import * as React from 'react';
|
||||
import { Provider } from 'react-redux';
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
import I18nProvider from 'amo/i18n/Provider';
|
||||
import {
|
||||
createFakeDebounce,
|
||||
createFakeEvent,
|
||||
|
@ -37,6 +40,17 @@ describe(__filename, () => {
|
|||
);
|
||||
};
|
||||
|
||||
const mountRender = (customProps = {}) => {
|
||||
const props = renderProps(customProps);
|
||||
return mount(
|
||||
<I18nProvider i18n={props.i18n}>
|
||||
<Provider store={props.store}>
|
||||
<DismissibleTextForm {...props} />
|
||||
</Provider>
|
||||
</I18nProvider>,
|
||||
);
|
||||
};
|
||||
|
||||
const typeSomeText = ({ root, text }) => {
|
||||
// Simulate typing in a textarea.
|
||||
root.find('.DismissibleTextForm-textarea').simulate(
|
||||
|
@ -104,6 +118,14 @@ describe(__filename, () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('focuses the textarea on mount', () => {
|
||||
mountRender();
|
||||
// This checks that textarea.focus() was called.
|
||||
expect(document.activeElement.className).toEqual(
|
||||
'DismissibleTextForm-textarea',
|
||||
);
|
||||
});
|
||||
|
||||
it('calls back when dismissing the textarea', () => {
|
||||
const onDismiss = sinon.stub();
|
||||
const root = shallowRender({ onDismiss });
|
||||
|
|
|
@ -395,7 +395,7 @@ describe(__filename, () => {
|
|||
it('prompts to delete a review when beginningToDeleteReview', () => {
|
||||
const addon = createInternalAddonWithLang({
|
||||
...fakeAddon,
|
||||
name: createLocalizedString('uBlock Origin'),
|
||||
name: 'uBlock Origin',
|
||||
});
|
||||
const review = { ...fakeReview, body: 'This add-on is nice' };
|
||||
const { userId, store } = createStoreWithLatestReview({ addon, review });
|
||||
|
@ -411,7 +411,7 @@ describe(__filename, () => {
|
|||
it('prompts to delete a rating when beginningToDeleteReview', () => {
|
||||
const addon = createInternalAddonWithLang({
|
||||
...fakeAddon,
|
||||
name: createLocalizedString('uBlock Origin'),
|
||||
name: 'uBlock Origin',
|
||||
});
|
||||
const review = { ...fakeReview, body: undefined, score: 4 };
|
||||
const { userId, store } = createStoreWithLatestReview({ addon, review });
|
||||
|
|
|
@ -62,6 +62,9 @@ describe(__filename, () => {
|
|||
|
||||
const root = render({ addon });
|
||||
|
||||
expect(root.find('.StaticAddonCard-summary').html()).not.toContain(
|
||||
addon.summary,
|
||||
);
|
||||
expect(root.find('.StaticAddonCard-summary').html()).toContain(
|
||||
addon.description,
|
||||
);
|
||||
|
|
1439
yarn.lock
1439
yarn.lock
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче