From 84b680f3c2c0a43d6c0e17ec83651e7da5e1294d Mon Sep 17 00:00:00 2001 From: ehsan Date: Thu, 22 Oct 2020 17:27:06 +0100 Subject: [PATCH 1/4] Tests fix for extractSourceMap --- .../src/__tests__/extract-source-map.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/packages/react-error-overlay/src/__tests__/extract-source-map.js b/packages/react-error-overlay/src/__tests__/extract-source-map.js index b47f5ab5f6d..e0a50cb142e 100644 --- a/packages/react-error-overlay/src/__tests__/extract-source-map.js +++ b/packages/react-error-overlay/src/__tests__/extract-source-map.js @@ -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}.`); }); From 7105d6dfa1b8adc40a16f601130458197fc4bc3b Mon Sep 17 00:00:00 2001 From: ehsan Date: Thu, 22 Oct 2020 17:45:17 +0100 Subject: [PATCH 2/4] Tests fix for extractSourceMap - generic and get-source-map --- .../src/__tests__/get-source-map.js | 14 ++++------ .../src/__tests__/parser/generic.js | 28 ++++++++----------- 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/packages/react-error-overlay/src/__tests__/get-source-map.js b/packages/react-error-overlay/src/__tests__/get-source-map.js index 27c6d5f7893..e7ad0ee38aa 100644 --- a/packages/react-error-overlay/src/__tests__/get-source-map.js +++ b/packages/react-error-overlay/src/__tests__/get-source-map.js @@ -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.') + ); }); diff --git a/packages/react-error-overlay/src/__tests__/parser/generic.js b/packages/react-error-overlay/src/__tests__/parser/generic.js index 32bade9311f..45a5fa93943 100644 --- a/packages/react-error-overlay/src/__tests__/parser/generic.js +++ b/packages/react-error-overlay/src/__tests__/parser/generic.js @@ -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.') + ); }); From 93062ddd3348d145d190deaaf5d88d350661f558 Mon Sep 17 00:00:00 2001 From: ehsan Date: Sat, 24 Oct 2020 15:07:45 +0100 Subject: [PATCH 3/4] plugin-syntax-jsx fix for Simple tasks --- tasks/e2e-simple.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index 506df4ff430..8a90c02e421 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -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 From 44484783709861261176e935cb5101424c9281c4 Mon Sep 17 00:00:00 2001 From: ehsan Date: Sun, 25 Oct 2020 19:25:17 +0000 Subject: [PATCH 4/4] Ejected app tests - fix for react-app babel preset --- packages/react-scripts/scripts/eject.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index 2a494ffe24f..5d465ba8ee0 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -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