Skip to content

Commit e6ea4c5

Browse files
committed
build: Move build related unit test into own job
We shouldn't be asserting on built assets (dist/esm) in our unit tests. This helps unblock #4616
1 parent dee05a6 commit e6ea4c5

File tree

5 files changed

+35
-25
lines changed

5 files changed

+35
-25
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,11 @@ jobs:
411411
with:
412412
path: ${{ env.CACHED_BUILD_PATHS }}
413413
key: ${{ env.BUILD_CACHE_KEY }}
414-
- name: Run build tests
414+
- name: Run browser build tests
415415
run: |
416416
cd packages/browser
417417
yarn test:package
418+
- name: Run utils build tests
419+
run: |
420+
cd packages/utils
421+
yarn test:package

packages/utils/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*.js.map
22
*.d.ts
33
*.js
4+
!test/package/build.js
45
!.eslintrc.js

packages/utils/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
4646
"pack": "npm pack",
4747
"test": "jest",
48-
"test:watch": "jest --watch"
48+
"test:watch": "jest --watch",
49+
"test:package": "node test/package/build.js"
4950
},
5051
"volta": {
5152
"extends": "../../package.json"

packages/utils/test/build.test.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

packages/utils/test/package/build.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
const testStrings = [`/// <reference types="node" />`];
5+
6+
const paths = [path.join('./dist'), path.join('./esm')];
7+
8+
paths.forEach(dir => {
9+
if (!fs.existsSync(dir)) {
10+
// eslint-disable-next-line no-console
11+
console.error(`${dir} doesn't exist please build first`);
12+
process.exit(1);
13+
}
14+
const files = fs.readdirSync(dir);
15+
files.forEach(file => {
16+
if (file.includes('.d.ts')) {
17+
testStrings.forEach(testString => {
18+
const filePath = path.join(dir, file)
19+
if (fs.readFileSync(filePath, 'utf8').includes(testString)) {
20+
// eslint-disable-next-line no-console
21+
console.error(`${filePath} contains types`);
22+
process.exit(1);
23+
}
24+
});
25+
}
26+
});
27+
});

0 commit comments

Comments
 (0)