Skip to content

Commit 66ce161

Browse files
committed
Add regression test for Jest --findRelatedTests behavior
- a lint rule might be better long-term, but this will at least warn us if our hook starts running extra tests again
1 parent e4b32fe commit 66ce161

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

scripts/tests/test-staged.test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const { execSync } = require('child_process');
2+
const path = require('path');
3+
const euiRoot = path.resolve(__dirname, '../../');
4+
5+
describe('test-staged.js', () => {
6+
it('does not have --findRelatedTests regressions due to imports from src/components', () => {
7+
const outputString = execSync(
8+
'yarn test-unit --findRelatedTests --listTests src/components/beacon/beacon.tsx',
9+
{ cwd: euiRoot }
10+
).toString();
11+
const output = outputString
12+
.split('\n')
13+
.filter((item) => item.includes('eui/src/components'));
14+
15+
expect(
16+
output[0].endsWith('eui/src/components/tour/tour_step.test.tsx')
17+
).toBeTruthy();
18+
expect(
19+
output[1].endsWith('eui/src/components/beacon/beacon.test.tsx')
20+
).toBeTruthy();
21+
22+
expect(output[2]).toBeUndefined();
23+
});
24+
});

0 commit comments

Comments
 (0)