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

Simple Tasks fixes and Fix #9953 #9858

Closed
wants to merge 7 commits into from
14 changes: 5 additions & 9 deletions packages/react-error-overlay/src/__tests__/extract-source-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,12 @@ test('extracts last source map directive', async () => {
expect(res).toBe('bundle.js.map');
});

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

const testFileName = 'test.js';
try {
await extractSourceMapUrl(
testFileName,
`console.log('hi')\n\nconsole.log('bye')`
);
} catch (e) {
expect(e).toBe(`Cannot find a source map directive for ${testFileName}.`);
}

await expect(
extractSourceMapUrl(testFileName, `console.log('hi')\n\nconsole.log('bye')`)
).rejects.toEqual(`Cannot find a source map directive for ${testFileName}.`);
});
14 changes: 5 additions & 9 deletions packages/react-error-overlay/src/__tests__/get-source-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,13 @@ test('find an inline source map', async () => {
});

test('error on a source map with unsupported encoding', async () => {
expect.assertions(2);
expect.assertions(1);

const file = fs
.readFileSync(resolve(__dirname, '../../fixtures/junk-inline.mjs'))
.toString('utf8');
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.'
);
}

await expect(getSourceMap('/', file)).rejects.toThrowError(
new Error('Sorry, non-base64 inline source-map encoding is not supported.')
);
});
28 changes: 11 additions & 17 deletions packages/react-error-overlay/src/__tests__/parser/generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,18 @@

import { parse } from '../../utils/parser';

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

expect(() => parse(null)).toThrowError(
new Error('You cannot pass a null object.')
);
});

test('throws on unparsable', () => {
expect.assertions(2);
try {
parse({});
} catch (e) {
expect(e instanceof Error).toBe(true);
expect(e.message).toBe(
'The error you provided does not contain a stack trace.'
);
}
expect.assertions(1);

expect(() => parse({})).toThrowError(
new Error('The error you provided does not contain a stack trace.')
);
});
2 changes: 1 addition & 1 deletion packages/react-scripts/scripts/eject.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ inquirer
// Add Babel config
console.log(` Adding ${cyan('Babel')} preset`);
appPackage.babel = {
presets: ['react-app'],
presets: [['react-app', { runtime: 'automatic' }]],
};

// Add ESlint config
Expand Down
1 change: 1 addition & 0 deletions tasks/e2e-simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ echo yes | npm run eject
test -n "$(git diff --staged --name-only)"

# Test the build
yarn add @babel/plugin-syntax-jsx
yarn build
# Check for expected output
exists build/*.html
Expand Down