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 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/cra-template-typescript/template/gitignore
Expand Up @@ -17,6 +17,7 @@
.env.development.local
.env.test.local
.env.production.local
.eslintcache
Copy link
Contributor

@raix raix Dec 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this would be fixed by #10177 (but this pr should not be blocked by it - honestly better to get it merged)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 4bf2990. Now some of the recovered tests will be temporarily broken but I think it's ok.


npm-debug.log*
yarn-debug.log*
Expand Down
1 change: 1 addition & 0 deletions packages/cra-template/template/gitignore
Expand Up @@ -17,6 +17,7 @@
.env.development.local
.env.test.local
.env.production.local
.eslintcache

npm-debug.log*
yarn-debug.log*
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dev-utils/package.json
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
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
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
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
@@ -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
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
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
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