-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Run behavioral smoke tests with Jest, add output tests #5150
Merged
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9f333d7
Run smoke tests with Jest
Timer 8509f76
Get a unique port for smoke test
Timer 02f72bd
Upgrade verdaccio across the board
Timer f01b962
Drop unneeded step
Timer 0755f9d
Try latest instead
Timer 75af8a8
Boot registry in home directory
Timer b838a4c
Correct config path
Timer 5669bdc
Add mutex
Timer 261a933
Test webpack message formatting
Timer 6970168
Strip color
Timer 41d0e36
Add browserslist to default
Timer fd57909
Disable another broken feature
Timer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
testEnvironment: 'node', | ||
testMatch: ['**/*.test.js'], | ||
setupTestFrameworkScriptFile: './setupOutputTests.js', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
102 changes: 102 additions & 0 deletions
102
fixtures/output/webpack-message-formatting/__snapshots__/index.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": "", | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
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(); | ||
}); | ||
|
||
it('formats unknown export', async () => { | ||
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(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"dependencies": { | ||
"node-sass": "4.x", | ||
"react": "latest", | ||
"react-dom": "latest", | ||
"react-scripts": "latest" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
13 changes: 13 additions & 0 deletions
13
fixtures/output/webpack-message-formatting/src/AppBabel.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.App { | ||
color: red; | ||
}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
13 changes: 13 additions & 0 deletions
13
fixtures/output/webpack-message-formatting/src/AppLintError.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
11 changes: 11 additions & 0 deletions
11
fixtures/output/webpack-message-formatting/src/AppLintWarning.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
13 changes: 13 additions & 0 deletions
13
fixtures/output/webpack-message-formatting/src/AppMissingPackage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
13 changes: 13 additions & 0 deletions
13
fixtures/output/webpack-message-formatting/src/AppUnknownExport.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function foo() { | ||
console.log('bar'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@import "~bootstrap/scss/bootstrap.scss"; |
17 changes: 17 additions & 0 deletions
17
fixtures/smoke/builds-with-multiple-runtimes/index.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"dependencies": { | ||
"dva": "2.4.0", | ||
"ky": "0.3.0", | ||
"react": "latest", | ||
"react-dom": "latest", | ||
"react-scripts": "latest" | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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. 😍😍😍