Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 26.9k
Run behavioral smoke tests with Jest, add output tests#5150
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
9f333d78509f7602f72bdf01b9620755f9d75af8a8b838a4c5669bdc261a933697016841d0e36fd57909File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| module.exports = { | ||
| testEnvironment: 'node', | ||
| testMatch: ['**/*.test.js'], | ||
| setupTestFrameworkScriptFile: './setupOutputTests.js', | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| beforeAll(() => { | ||
| jest.setTimeout(1000 * 60 * 5); | ||
| }); | ||
| beforeEach(() => { | ||
| jest.setTimeout(1000 * 60 * 5); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
| exports[`webpack message formatting formats babel syntax error 1`] = ` | ||
| Object { | ||
| "stderr": "Creating an optimized production build... | ||
| Failed to compile. | ||
| ./src/App.js | ||
| Syntax error: Unterminated JSX contents (8:12) | ||
| 6 | <div> | ||
| 7 | <span> | ||
| > 8 | </div> | ||
| | ^ | ||
| 9 | ); | ||
| 10 | } | ||
| 11 | } | ||
| ", | ||
| "stdout": "", | ||
| } | ||
| `; | ||
| exports[`webpack message formatting formats css syntax error 1`] = ` | ||
| Object { | ||
| "stderr": "Creating an optimized production build... | ||
| [31mFailed to compile. | ||
| [39m | ||
| [7m./src/AppCss.css[27m | ||
| Syntax Error: (3:2) Unexpected } | ||
| [90m 1 | [39m[33m.App[39m [33m{[39m | ||
| [90m 2 | [39m color[33m:[39m red[33m;[39m | ||
| [31m[1m>[22m[39m[90m 3 | [39m[33m}[39m[33m}[39m | ||
| [90m | [39m [31m[1m^[22m[39m | ||
| [90m 4 | [39m | ||
| ", | ||
| "stdout": "", | ||
| } | ||
| `; | ||
| exports[`webpack message formatting formats eslint error 1`] = ` | ||
| Object { | ||
| "stderr": "Creating an optimized production build... | ||
| Failed to compile. | ||
| ./src/App.js | ||
| Line 4: 'b' is not defined no-undef | ||
| Search for the keywords to learn more about each error. | ||
| ", | ||
| "stdout": "", | ||
| } | ||
| `; | ||
| exports[`webpack message formatting formats eslint warning 1`] = ` | ||
| Object { | ||
| "stderr": "", | ||
| "stdout": "Creating an optimized production build... | ||
| Compiled with warnings. | ||
| ./src/App.js | ||
| Line 3: 'foo' is defined but never used no-unused-vars | ||
| Search for the keywords to learn more about each warning. | ||
| To ignore, add // eslint-disable-next-line to the line before. | ||
| ", | ||
| } | ||
| `; | ||
| exports[`webpack message formatting formats missing package 1`] = ` | ||
| Object { | ||
| "stderr": "Creating an optimized production build... | ||
| [31mFailed to compile. | ||
| [39m | ||
| Module not found: Error: Can't resolve 'unknown-package' in '/private/var/folders/c3/vytj6_h56b77f_g72smntm3m0000gn/T/bf26e1d3700ad14275f6eefb5e4417c1/src' | ||
| ", | ||
| "stdout": "", | ||
| } | ||
| `; | ||
| exports[`webpack message formatting formats unknown export 1`] = ` | ||
| Object { | ||
| "stderr": "Creating an optimized production build... | ||
| Failed to compile. | ||
| ./src/App.js | ||
| 1:1677-1680 './AppUnknownExport' does not contain an export named 'bar'. | ||
| ", | ||
| "stdout": "", | ||
| } | ||
| `; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| const { bootstrap, getOutputProduction } = require('../../utils'); | ||
| const fs = require('fs-extra'); | ||
| const path = require('path'); | ||
| const Semaphore = require('async-sema'); | ||
| const tempy = require('tempy'); | ||
| describe('webpack message formatting', () => { | ||
| const semaphore = new Semaphore(1, { capacity: Infinity }); | ||
| let testDirectory; | ||
| beforeAll(async () => { | ||
| testDirectory = tempy.directory(); | ||
| await bootstrap({ directory: testDirectory, template: __dirname }); | ||
| }); | ||
| beforeEach(async () => { | ||
| await semaphore.acquire(); | ||
| }); | ||
| afterEach(async () => { | ||
| fs.removeSync(path.join(testDirectory, 'src', 'App.js')); | ||
| semaphore.release(); | ||
| }); | ||
| it('formats babel syntax error', async () => { | ||
| fs.copySync( | ||
| path.join(__dirname, 'src', 'AppBabel.js'), | ||
| path.join(testDirectory, 'src', 'App.js') | ||
| ); | ||
| const response = await getOutputProduction({ directory: testDirectory }); | ||
| expect(response).toMatchSnapshot(); | ||
| }); | ||
| xit('formats css syntax error', async () => { | ||
| // TODO: fix me! | ||
| fs.copySync( | ||
| path.join(__dirname, 'src', 'AppCss.js'), | ||
| path.join(testDirectory, 'src', 'App.js') | ||
| ); | ||
| const response = await getOutputProduction({ directory: testDirectory }); | ||
| expect(response).toMatchSnapshot(); | ||
| }); | ||
| xit('formats unknown export', async () => { | ||
| // TODO: fix me! | ||
| fs.copySync( | ||
| path.join(__dirname, 'src', 'AppUnknownExport.js'), | ||
| path.join(testDirectory, 'src', 'App.js') | ||
| ); | ||
| const response = await getOutputProduction({ directory: testDirectory }); | ||
| expect(response).toMatchSnapshot(); | ||
| }); | ||
| xit('formats missing package', async () => { | ||
| // TODO: fix me! | ||
| fs.copySync( | ||
| path.join(__dirname, 'src', 'AppMissingPackage.js'), | ||
| path.join(testDirectory, 'src', 'App.js') | ||
| ); | ||
| const response = await getOutputProduction({ directory: testDirectory }); | ||
| expect(response).toMatchSnapshot(); | ||
| }); | ||
| it('formats eslint warning', async () => { | ||
| fs.copySync( | ||
| path.join(__dirname, 'src', 'AppLintWarning.js'), | ||
| path.join(testDirectory, 'src', 'App.js') | ||
| ); | ||
| const response = await getOutputProduction({ directory: testDirectory }); | ||
| const sizeIndex = response.stdout.indexOf('File sizes after gzip'); | ||
| if (sizeIndex !== -1) { | ||
| response.stdout = response.stdout.substring(0, sizeIndex); | ||
| } | ||
| expect(response).toMatchSnapshot(); | ||
| }); | ||
| it('formats eslint error', async () => { | ||
| fs.copySync( | ||
| path.join(__dirname, 'src', 'AppLintError.js'), | ||
| path.join(testDirectory, 'src', 'App.js') | ||
| ); | ||
| const response = await getOutputProduction({ directory: testDirectory }); | ||
| expect(response).toMatchSnapshot(); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "dependencies": { | ||
| "node-sass": "4.x", | ||
| "react": "latest", | ||
| "react-dom": "latest", | ||
| "react-scripts": "latest" | ||
| }, | ||
| "browserslist": [ | ||
| ">0.2%" | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <title>React App</title> | ||
| </head> | ||
| <body> | ||
| <div id="root"></div> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import React, { Component } from 'react'; | ||
| class App extends Component { | ||
| render() { | ||
| return ( | ||
| <div> | ||
| <span> | ||
| </div> | ||
| ); | ||
| } | ||
| } | ||
| export default App; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| .App { | ||
| color: red; | ||
| }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import React, { Component } from 'react'; | ||
| import './AppCss.css'; | ||
| class App extends Component { | ||
| render() { | ||
| return <div className="App" />; | ||
| } | ||
| } | ||
| export default App; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import React, { Component } from 'react'; | ||
| function foo() { | ||
| const a = b; | ||
| } | ||
| class App extends Component { | ||
| render() { | ||
| return <div />; | ||
| } | ||
| } | ||
| export default App; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import React, { Component } from 'react'; | ||
| function foo() {} | ||
| class App extends Component { | ||
| render() { | ||
| return <div />; | ||
| } | ||
| } | ||
| export default App; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import React, { Component } from 'react'; | ||
| import { bar } from 'unknown-package'; | ||
| class App extends Component { | ||
| componentDidMount() { | ||
| bar(); | ||
| } | ||
| render() { | ||
| return <div />; | ||
| } | ||
| } | ||
| export default App; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import React, { Component } from 'react'; | ||
| import { bar } from './AppUnknownExport'; | ||
| class App extends Component { | ||
| componentDidMount() { | ||
| bar(); | ||
| } | ||
| render() { | ||
| return <div />; | ||
| } | ||
| } | ||
| export default App; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export function foo() { | ||
| console.log('bar'); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import React from 'react'; | ||
| import ReactDOM from 'react-dom'; | ||
| import App from './App'; | ||
| ReactDOM.render(<App />, document.getElementById('root')); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| const { | ||
| bootstrap, | ||
| isSuccessfulDevelopment, | ||
| isSuccessfulProduction, | ||
| } = require('../../utils'); | ||
| beforeEach(async () => { | ||
| await bootstrap({ directory: global.testDirectory, template: __dirname }); | ||
| }); | ||
| describe('bootstrap sass', () => { | ||
| it('builds in development', async () => { | ||
| await isSuccessfulDevelopment({ directory: global.testDirectory }); | ||
| }); | ||
| it('builds in production', async () => { | ||
| await isSuccessfulProduction({ directory: global.testDirectory }); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "dependencies": { | ||
| "bootstrap": "4.x", | ||
| "node-sass": "4.x", | ||
| "react": "latest", | ||
| "react-dom": "latest", | ||
| "react-scripts": "latest" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <title>React App</title> | ||
| </head> | ||
| <body> | ||
| <div id="root"></div> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import React from 'react'; | ||
| import ReactDOM from 'react-dom'; | ||
| import './index.sass'; | ||
| ReactDOM.render(<div />, document.getElementById('root')); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| @import "~bootstrap/scss/bootstrap.scss"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| const { | ||
| bootstrap, | ||
| isSuccessfulDevelopment, | ||
| isSuccessfulProduction, | ||
| } = require('../../utils'); | ||
| beforeEach(async () => { | ||
| await bootstrap({ directory: global.testDirectory, template: __dirname }); | ||
| }); | ||
| describe('builds-with-multiple-runtimes', () => { | ||
| it('builds in development', async () => { | ||
| await isSuccessfulDevelopment({ directory: global.testDirectory }); | ||
| }); | ||
| it('builds in production', async () => { | ||
| await isSuccessfulProduction({ directory: global.testDirectory }); | ||
| }); | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OMG this is so great. 😍😍😍