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/src/App.js b/fixtures/smoke/issue-5176-flow-class-properties/src/App.js new file mode 100644 index 0000000000000000000000000000000000000000..25e20018c0375f86f3ab5ca520cb8cfc8ee246af --- /dev/null +++ b/fixtures/smoke/issue-5176-flow-class-properties/src/App.js @@ -0,0 +1,12 @@ +class App { + constructor(props) { + super(props); + 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/utils.js b/fixtures/utils.js index 2bcab03c4a2de96261c87681c28b7cac930a5bd5..2f20d78a95a8a9b055bf682f0ce284b465c620e2 100644 --- a/fixtures/utils.js +++ b/fixtures/utils.js @@ -67,6 +67,21 @@ async function isSuccessfulProduction({ directory }) { } } +async function isSuccessfulTest({ directory, jestEnvironment = 'jsdom' }) { + const { status, stdout, stderr } = await execa( + './node_modules/.bin/react-scripts', + ['test', '--env', jestEnvironment, '--ci'], + { + cwd: directory, + env: { CI: 'true' }, + } + ); + + if (status !== 0) { + throw new Error(`stdout: ${stdout}${os.EOL + os.EOL}stderr: ${stderr}`); + } +} + async function getOutputDevelopment({ directory, env = {} }) { try { const { stdout, stderr } = await execa( @@ -128,6 +143,7 @@ module.exports = { bootstrap, isSuccessfulDevelopment, isSuccessfulProduction, + isSuccessfulTest, getOutputDevelopment, getOutputProduction, };