Skip to content
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

Recovered some integration tests #10091

Merged
merged 7 commits into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
},
"devDependencies": {
"cross-env": "^7.0.2",
"jest": "26.4.2"
"jest": "26.6.0"
},
"scripts": {
"test": "cross-env FORCE_COLOR=true jest"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ test('extracts last source map directive', async () => {
});

test('errors when no source map', async () => {
expect.assertions(1);

const testFileName = 'test.js';
let error;
try {
await extractSourceMapUrl(
testFileName,
`console.log('hi')\n\nconsole.log('bye')`
);
} catch (e) {
expect(e).toBe(`Cannot find a source map directive for ${testFileName}.`);
error = e;
}
expect(error).toBe(`Cannot find a source map directive for ${testFileName}.`);
});
10 changes: 6 additions & 4 deletions packages/react-error-overlay/src/__tests__/get-source-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ test('error on a source map with unsupported encoding', async () => {
const file = fs
.readFileSync(resolve(__dirname, '../../fixtures/junk-inline.mjs'))
.toString('utf8');
let error;
try {
await getSourceMap('/', file);
} catch (e) {
expect(e instanceof Error).toBe(true);
expect(e.message).toBe(
'Sorry, non-base64 inline source-map encoding is not supported.'
);
error = e;
}
expect(error instanceof Error).toBe(true);
expect(error.message).toBe(
'Sorry, non-base64 inline source-map encoding is not supported.'
);
});
18 changes: 10 additions & 8 deletions packages/react-error-overlay/src/__tests__/parser/generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,25 @@
import { parse } from '../../utils/parser';

test('throws on null', () => {
expect.assertions(2);
let error;
try {
parse(null);
} catch (e) {
expect(e instanceof Error).toBe(true);
expect(e.message).toBe('You cannot pass a null object.');
error = e;
}
expect(error instanceof Error).toBe(true);
expect(error.message).toBe('You cannot pass a null object.');
});

test('throws on unparsable', () => {
expect.assertions(2);
let error;
try {
parse({});
} catch (e) {
expect(e instanceof Error).toBe(true);
expect(e.message).toBe(
'The error you provided does not contain a stack trace.'
);
error = e;
}
expect(error instanceof Error).toBe(true);
expect(error.message).toBe(
'The error you provided does not contain a stack trace.'
);
});
3 changes: 2 additions & 1 deletion packages/react-scripts/config/jest/babelTransform.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// @remove-file-on-eject
// @remove-on-eject-begin
/**
maxsbelt marked this conversation as resolved.
Show resolved Hide resolved
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// @remove-on-eject-end
'use strict';

const babelJest = require('babel-jest');
Expand Down
2 changes: 1 addition & 1 deletion packages/react-scripts/fixtures/kitchensink/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"package": {
"dependencies": {
"bootstrap": "4.3.1",
"jest": "26.4.2",
"jest": "26.6.0",
"node-sass": "4.x",
"normalize.css": "7.0.0",
"prop-types": "15.7.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('Integration', () => {
doc = await initDOM('image-inclusion');

expect(doc.getElementById('feature-image-inclusion').src).toMatch(
/^data:image\/jpeg;base64.+==$/
/^data:image\/jpeg;base64.+=$/
);
});

Expand Down
6 changes: 3 additions & 3 deletions packages/react-scripts/scripts/utils/createJestConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ module.exports = (resolve, rootDir, isEjecting) => {
testEnvironment: 'jsdom',
testRunner: require.resolve('jest-circus/runner'),
transform: {
'^.+\\.(js|jsx|mjs|cjs|ts|tsx)$': isEjecting
? '<rootDir>/node_modules/babel-jest'
: resolve('config/jest/babelTransform.js'),
'^.+\\.(js|jsx|mjs|cjs|ts|tsx)$': resolve(
'config/jest/babelTransform.js'
),
'^.+\\.css$': resolve('config/jest/cssTransform.js'),
'^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)': resolve(
'config/jest/fileTransform.js'
Expand Down