Skip to content

Commit adab94c

Browse files
chore: disable flaky tests (#2230)
* chore: skip flaky tests * fix: skip only on node v20
1 parent 043c831 commit adab94c

File tree

1 file changed

+32
-22
lines changed

1 file changed

+32
-22
lines changed

packages/cli/src/tools/__tests__/copyFiles.test.ts

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import path from 'path';
33
import copyFiles from '../copyFiles';
44
import {cleanup, getTempDirectory} from '../../../../../jest/helpers';
55
import replacePathSepForRegex from '../replacePathSepForRegex';
6+
import semver from 'semver';
67

78
const DIR = getTempDirectory('copyFiles-test');
89

@@ -15,11 +16,16 @@ afterEach(() => {
1516
cleanup(DIR);
1617
});
1718

18-
test('copies text and binary files from source to destination', async () => {
19-
const src = path.resolve(__dirname, './__fixtures__');
20-
await copyFiles(src, DIR);
19+
// FIXME Flaky test on Ubuntu Node v20
20+
const skipIfNode20 = semver.major(process.version) === 20 ? test.skip : test;
2121

22-
expect(fs.readdirSync(DIR)).toMatchInlineSnapshot(`
22+
skipIfNode20(
23+
'copies text and binary files from source to destination',
24+
async () => {
25+
const src = path.resolve(__dirname, './__fixtures__');
26+
await copyFiles(src, DIR);
27+
28+
expect(fs.readdirSync(DIR)).toMatchInlineSnapshot(`
2329
Array [
2430
"binary.keystore",
2531
"extraDir",
@@ -28,34 +34,38 @@ test('copies text and binary files from source to destination', async () => {
2834
]
2935
`);
3036

31-
['binary.keystore', 'file1.js', 'file2.txt'].forEach((file) => {
32-
expect(fs.readFileSync(path.join(src, file))).toEqual(
33-
fs.readFileSync(path.join(DIR, file)),
34-
);
35-
});
37+
['binary.keystore', 'file1.js', 'file2.txt'].forEach((file) => {
38+
expect(fs.readFileSync(path.join(src, file))).toEqual(
39+
fs.readFileSync(path.join(DIR, file)),
40+
);
41+
});
3642

37-
expect(fs.readdirSync(path.join(DIR, 'extraDir'))).toMatchInlineSnapshot(`
43+
expect(fs.readdirSync(path.join(DIR, 'extraDir'))).toMatchInlineSnapshot(`
3844
Array [
3945
"file3",
4046
]
4147
`);
4248

43-
expect(fs.readFileSync(path.join(src, 'extraDir', 'file3'))).toEqual(
44-
fs.readFileSync(path.join(DIR, 'extraDir', 'file3')),
45-
);
46-
});
49+
expect(fs.readFileSync(path.join(src, 'extraDir', 'file3'))).toEqual(
50+
fs.readFileSync(path.join(DIR, 'extraDir', 'file3')),
51+
);
52+
},
53+
);
4754

48-
test('copies files from source to destination excluding directory', async () => {
49-
const src = path.resolve(__dirname, './__fixtures__');
50-
let regexStr = path.join(src, 'extraDir');
51-
await copyFiles(src, DIR, {
52-
exclude: [new RegExp(replacePathSepForRegex(regexStr))],
53-
});
54-
expect(fs.readdirSync(DIR)).toMatchInlineSnapshot(`
55+
skipIfNode20(
56+
'copies files from source to destination excluding directory',
57+
async () => {
58+
const src = path.resolve(__dirname, './__fixtures__');
59+
let regexStr = path.join(src, 'extraDir');
60+
await copyFiles(src, DIR, {
61+
exclude: [new RegExp(replacePathSepForRegex(regexStr))],
62+
});
63+
expect(fs.readdirSync(DIR)).toMatchInlineSnapshot(`
5564
Array [
5665
"binary.keystore",
5766
"file1.js",
5867
"file2.txt",
5968
]
6069
`);
61-
});
70+
},
71+
);

0 commit comments

Comments
 (0)