diff --git a/fixtures/smoke/issue-5176-flow-class-properties/index.test.js b/fixtures/smoke/issue-5176-flow-class-properties/index.test.js new file mode 100644 index 0000000000000000000000000000000000000000..72a7a3daf0e3e146e1b9a729f29787b47bbf096a --- /dev/null +++ b/fixtures/smoke/issue-5176-flow-class-properties/index.test.js @@ -0,0 +1,13 @@ +const { bootstrap, isSuccessfulTest } = require('../../utils'); +beforeEach(async () => { + await bootstrap({ directory: global.testDirectory, template: __dirname }); +}); + +describe('issue #5176 (flow class properties interaction)', () => { + it('passes tests', async () => { + await isSuccessfulTest({ + directory: global.testDirectory, + jestEnvironment: 'node', + }); + }); +}); diff --git a/fixtures/smoke/issue-5176-flow-class-properties/package.json b/fixtures/smoke/issue-5176-flow-class-properties/package.json new file mode 100644 index 0000000000000000000000000000000000000000..0967ef424bce6791893e9a57bb952f80fd536e93 --- /dev/null +++ b/fixtures/smoke/issue-5176-flow-class-properties/package.json @@ -0,0 +1 @@ +{} diff --git a/fixtures/smoke/issue-5176-flow-class-properties/public/index.html b/fixtures/smoke/issue-5176-flow-class-properties/public/index.html new file mode 100644 index 0000000000000000000000000000000000000000..86010b2406754a56929e9dd5beee345cb8b72192 --- /dev/null +++ b/fixtures/smoke/issue-5176-flow-class-properties/public/index.html @@ -0,0 +1,9 @@ +<!DOCTYPE html> + <html lang="en"> + <head> + <title>React App</title> + </head> + <body> + <div id="root"></div> + </body> +</html> diff --git a/fixtures/smoke/issue-5176-flow-class-properties/src/App.js b/fixtures/smoke/issue-5176-flow-class-properties/src/App.js new file mode 100644 index 0000000000000000000000000000000000000000..c6a68613b58c26e45750c4129ed4cf0d1ff5ed97 --- /dev/null +++ b/fixtures/smoke/issue-5176-flow-class-properties/src/App.js @@ -0,0 +1,11 @@ +class App { + constructor() { + this.foo = this.foo.bind(this); + } + foo: void => void; + foo() { + return 'bar'; + } +} + +export default App; diff --git a/fixtures/smoke/issue-5176-flow-class-properties/src/App.test.js b/fixtures/smoke/issue-5176-flow-class-properties/src/App.test.js new file mode 100644 index 0000000000000000000000000000000000000000..4991b756f292119f7fcdebfaf4f5564a73add854 --- /dev/null +++ b/fixtures/smoke/issue-5176-flow-class-properties/src/App.test.js @@ -0,0 +1,6 @@ +import App from './App'; + +it('creates instance without', () => { + const app = new App(); + expect(app.foo()).toBe('bar'); +}); diff --git a/fixtures/smoke/jest.config.js b/fixtures/smoke/jest.config.js index 9057ec0ea714b19ce946fc7490d9f4df4c7ec9a8..b2f8182ebd9500626d3c935bab319e4cb99a8cb8 100644 --- a/fixtures/smoke/jest.config.js +++ b/fixtures/smoke/jest.config.js @@ -1,5 +1,6 @@ module.exports = { testEnvironment: 'node', testMatch: ['**/*.test.js'], + testPathIgnorePatterns: ['/src/', 'node_modules'], setupTestFrameworkScriptFile: './setupSmokeTests.js', }; diff --git a/fixtures/utils.js b/fixtures/utils.js index 2bcab03c4a2de96261c87681c28b7cac930a5bd5..bde092f6e3e5783d8937bc38b064aa4518965caf 100644 --- a/fixtures/utils.js +++ b/fixtures/utils.js @@ -14,7 +14,7 @@ async function bootstrap({ directory, template }) { ); if (shouldInstallScripts) { const packageJson = fs.readJsonSync(path.join(directory, 'package.json')); - packageJson.dependencies = Object.assign(packageJson.dependencies, { + packageJson.dependencies = Object.assign({}, packageJson.dependencies, { 'react-scripts': 'latest', }); fs.writeJsonSync(path.join(directory, 'package.json'), packageJson); @@ -67,6 +67,17 @@ async function isSuccessfulProduction({ directory }) { } } +async function isSuccessfulTest({ directory, jestEnvironment = 'jsdom' }) { + await execa( + './node_modules/.bin/react-scripts', + ['test', '--env', jestEnvironment, '--ci'], + { + cwd: directory, + env: { CI: 'true' }, + } + ); +} + async function getOutputDevelopment({ directory, env = {} }) { try { const { stdout, stderr } = await execa( @@ -128,6 +139,7 @@ module.exports = { bootstrap, isSuccessfulDevelopment, isSuccessfulProduction, + isSuccessfulTest, getOutputDevelopment, getOutputProduction, };