diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a430c311a16e..c35da85dd473 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/packages/utils/.gitignore b/packages/utils/.gitignore index 0bf02553e3a7..5c5f1c199d85 100644 --- a/packages/utils/.gitignore +++ b/packages/utils/.gitignore @@ -1,4 +1,5 @@ *.js.map *.d.ts *.js +!test/types/* !.eslintrc.js diff --git a/packages/utils/package.json b/packages/utils/package.json index 5291d8f6eb2e..7277cdc6dbd2 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -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/types/index.js" }, "volta": { "extends": "../../package.json" diff --git a/packages/utils/test/build.test.ts b/packages/utils/test/build.test.ts deleted file mode 100644 index 3f5184a02063..000000000000 --- a/packages/utils/test/build.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -import * as fs from 'fs'; -import * as path from 'path'; - -const testStrings = ['/// ']; - -describe('build', () => { - test('not contains types', () => { - const paths = [path.join('./dist'), path.join('./esm')]; - paths.forEach(dir => { - if (!fs.existsSync(dir)) { - expect(dir).toBe(`${dir} doesn't exist please build first`); - } - const files = fs.readdirSync(dir); - files.forEach(file => { - if (file.includes('.d.ts')) { - testStrings.forEach(testString => { - expect(fs.readFileSync(path.join(dir, file), 'utf8')).toEqual(expect.not.stringContaining(testString)); - }); - } - }); - }); - }); -}); diff --git a/packages/utils/test/types/index.js b/packages/utils/test/types/index.js new file mode 100644 index 000000000000..6fd6277f70bf --- /dev/null +++ b/packages/utils/test/types/index.js @@ -0,0 +1,27 @@ +const fs = require('fs'); +const path = require('path'); + +const testStrings = ['/// ']; + +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); + } + }); + } + }); +});