Skip to content

Commit

Permalink
build: Move build related unit test into own job
Browse files Browse the repository at this point in the history
We shouldn't be asserting on built assets (dist/esm) in our unit tests.

This helps unblock #4616
  • Loading branch information
AbhiPrasad committed Mar 1, 2022
1 parent dee05a6 commit e6ea4c5
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 25 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,11 @@ jobs:
with:
path: ${{ env.CACHED_BUILD_PATHS }}
key: ${{ env.BUILD_CACHE_KEY }}
- name: Run build tests
- name: Run browser build tests
run: |
cd packages/browser
yarn test:package
- name: Run utils build tests
run: |
cd packages/utils
yarn test:package
1 change: 1 addition & 0 deletions packages/utils/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.js.map
*.d.ts
*.js
!test/package/build.js
!.eslintrc.js
3 changes: 2 additions & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
"pack": "npm pack",
"test": "jest",
"test:watch": "jest --watch"
"test:watch": "jest --watch",
"test:package": "node test/package/build.js"
},
"volta": {
"extends": "../../package.json"
Expand Down
23 changes: 0 additions & 23 deletions packages/utils/test/build.test.ts

This file was deleted.

27 changes: 27 additions & 0 deletions packages/utils/test/package/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const fs = require('fs');
const path = require('path');

const testStrings = [`/// <reference types="node" />`];

const paths = [path.join('./dist'), path.join('./esm')];

paths.forEach(dir => {
if (!fs.existsSync(dir)) {
// eslint-disable-next-line no-console
console.error(`${dir} doesn't exist please build first`);
process.exit(1);
}
const files = fs.readdirSync(dir);
files.forEach(file => {
if (file.includes('.d.ts')) {
testStrings.forEach(testString => {
const filePath = path.join(dir, file)
if (fs.readFileSync(filePath, 'utf8').includes(testString)) {
// eslint-disable-next-line no-console
console.error(`${filePath} contains types`);
process.exit(1);
}
});
}
});
});

0 comments on commit e6ea4c5

Please sign in to comment.