Skip to content

Commit 946d1ad

Browse files
committed
Test flow types are stripped before class properties are transformed
1 parent 70b3110 commit 946d1ad

File tree

5 files changed

+48
-0
lines changed

5 files changed

+48
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const { bootstrap, isSuccessfulTest } = require('../../utils');
2+
beforeEach(async () => {
3+
await bootstrap({ directory: global.testDirectory, template: __dirname });
4+
});
5+
6+
describe('issue #5176 (flow class properties interaction)', () => {
7+
it('passes tests', async () => {
8+
await isSuccessfulTest({
9+
directory: global.testDirectory,
10+
jestEnvironment: 'node',
11+
});
12+
});
13+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class App {
2+
constructor(props) {
3+
super(props);
4+
this.foo = this.foo.bind(this);
5+
}
6+
foo: void => void;
7+
foo() {
8+
return 'bar';
9+
}
10+
}
11+
12+
export default App;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import App from './App';
2+
3+
it('creates instance without', () => {
4+
const app = new App();
5+
expect(app.foo()).toBe('bar');
6+
});

fixtures/utils.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,21 @@ async function isSuccessfulProduction({ directory }) {
6767
}
6868
}
6969

70+
async function isSuccessfulTest({ directory, jestEnvironment = 'jsdom' }) {
71+
const { status, stdout, stderr } = await execa(
72+
'./node_modules/.bin/react-scripts',
73+
['test', '--env', jestEnvironment, '--ci'],
74+
{
75+
cwd: directory,
76+
env: { CI: 'true' },
77+
}
78+
);
79+
80+
if (status !== 0) {
81+
throw new Error(`stdout: ${stdout}${os.EOL + os.EOL}stderr: ${stderr}`);
82+
}
83+
}
84+
7085
async function getOutputDevelopment({ directory, env = {} }) {
7186
try {
7287
const { stdout, stderr } = await execa(
@@ -128,6 +143,7 @@ module.exports = {
128143
bootstrap,
129144
isSuccessfulDevelopment,
130145
isSuccessfulProduction,
146+
isSuccessfulTest,
131147
getOutputDevelopment,
132148
getOutputProduction,
133149
};

0 commit comments

Comments
 (0)