Skip to content

Commit

Permalink
test: exports in barrel 😅
Browse files Browse the repository at this point in the history
  • Loading branch information
davidenke committed Oct 22, 2024
1 parent 53eddfd commit 591c761
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"eslint-plugin-prettier": "5.2.1",
"eslint-plugin-simple-import-sort": "12.1.1",
"eslint-plugin-unused-imports": "4.1.4",
"fast-glob": "3.3.2",
"highlight.js": "11.10.0",
"jest": "29.7.0",
"jest-junit": "16.0.0",
Expand Down
15 changes: 15 additions & 0 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { readFile } from 'node:fs/promises';

import glob from 'fast-glob';

const exports = await glob.async('src/{transformers,utils}/!(*.spec).ts', { onlyFiles: true });
const barrel = await readFile('./src/index.ts', 'utf-8');

describe('barrel', () => {
// lazy boy does not want to check all exports every time
// and neither does he want to generate the barrel file
it.each(exports)('exports %s', async file => {
const js = file.replace(/^src/, '.').replace(/\.ts$/, '.js');
expect(barrel).toEqual(expect.stringContaining(`export * from '${js}';`));
});
});

0 comments on commit 591c761

Please sign in to comment.