@@ -3,6 +3,7 @@ import path from 'path';
3
3
import copyFiles from '../copyFiles' ;
4
4
import { cleanup , getTempDirectory } from '../../../../../jest/helpers' ;
5
5
import replacePathSepForRegex from '../replacePathSepForRegex' ;
6
+ import semver from 'semver' ;
6
7
7
8
const DIR = getTempDirectory ( 'copyFiles-test' ) ;
8
9
@@ -15,11 +16,16 @@ afterEach(() => {
15
16
cleanup ( DIR ) ;
16
17
} ) ;
17
18
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 ;
21
21
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 ( `
23
29
Array [
24
30
"binary.keystore",
25
31
"extraDir",
@@ -28,34 +34,38 @@ test('copies text and binary files from source to destination', async () => {
28
34
]
29
35
` ) ;
30
36
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
+ } ) ;
36
42
37
- expect ( fs . readdirSync ( path . join ( DIR , 'extraDir' ) ) ) . toMatchInlineSnapshot ( `
43
+ expect ( fs . readdirSync ( path . join ( DIR , 'extraDir' ) ) ) . toMatchInlineSnapshot ( `
38
44
Array [
39
45
"file3",
40
46
]
41
47
` ) ;
42
48
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
+ ) ;
47
54
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 ( `
55
64
Array [
56
65
"binary.keystore",
57
66
"file1.js",
58
67
"file2.txt",
59
68
]
60
69
` ) ;
61
- } ) ;
70
+ } ,
71
+ ) ;
0 commit comments