Unverified Commit 946d1ad4 authored by Joe Haddad's avatar Joe Haddad
Browse files

Test flow types are stripped before class properties are transformed

parent 70b3110a
Showing with 48 additions and 0 deletions
+48 -0
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',
});
});
});
{}
class App {
constructor(props) {
super(props);
this.foo = this.foo.bind(this);
}
foo: void => void;
foo() {
return 'bar';
}
}
export default App;
import App from './App';
it('creates instance without', () => {
const app = new App();
expect(app.foo()).toBe('bar');
});
...@@ -67,6 +67,21 @@ async function isSuccessfulProduction({ directory }) { ...@@ -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 = {} }) { async function getOutputDevelopment({ directory, env = {} }) {
try { try {
const { stdout, stderr } = await execa( const { stdout, stderr } = await execa(
...@@ -128,6 +143,7 @@ module.exports = { ...@@ -128,6 +143,7 @@ module.exports = {
bootstrap, bootstrap,
isSuccessfulDevelopment, isSuccessfulDevelopment,
isSuccessfulProduction, isSuccessfulProduction,
isSuccessfulTest,
getOutputDevelopment, getOutputDevelopment,
getOutputProduction, getOutputProduction,
}; };
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment