Skip to content

Commit 8de3f16

Browse files
committed
chore(testing): Add code comment explaining package.json copying during build (#377)
1 parent 196682a commit 8de3f16

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/testing/build.mts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ fs.rmSync('./config', { recursive: true, force: true })
3434
fs.mkdirSync('./config')
3535
fs.cpSync('./dist/cjs/config', './config', { recursive: true })
3636
fs.cpSync('./dist/cjs/package.json', './config/package.json')
37+
// Some background on the two `fs.cpSync` calls below: I've been having problems
38+
// with jest testing in CI sometimes failing to find the jest preset file. I
39+
// don't know why. But after deep-diving into the jest source code I realized it
40+
// was looking for a package.json in the same directory as it first tries to
41+
// find the preset. It's supposed to traverse up the folder tree if it can't
42+
// find one, until it does. I'm not sure if this is sometimes failing, or what
43+
// happens when it finds one much further up the tree. Maybe jest then tries to
44+
// resolve the preset in *that* directory. Anyway, to make things as easy for it
45+
// as possible, I updated the testing package build script to put a package.json
46+
// files in the preset directories for both the api and the web sides. And after
47+
// that CI passed.
48+
// But since it's been flakey I don't know if this was the actual fix, or if it
49+
// just randomly decided to pass.
3750
fs.cpSync('./dist/cjs/package.json', './config/jest/api/package.json')
3851
fs.cpSync('./dist/cjs/package.json', './config/jest/web/package.json')
3952

0 commit comments

Comments
 (0)