Skip to content

Commit

Permalink
test: check for import failures from each module
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken committed Dec 7, 2021
1 parent 952eb03 commit 1b15074
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/unit/imports.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { execSync } from 'child_process';
import * as fs from 'fs';
import * as path from 'path';

function* walk(root) {
const directoryContents = fs.readdirSync(root);
for (const filepath of directoryContents) {
const fullPath = path.join(root, filepath);
const stat = fs.statSync(fullPath);
if (stat.isDirectory()) {
yield* walk(fullPath);
} else if (stat.isFile()) {
yield fullPath;
}
}
}

describe('importing mongodb driver', () => {
const sourceFiles = walk(path.resolve(__dirname, '../../src'));

for (const sourceFile of sourceFiles) {
const sliceFrom = sourceFile.indexOf('src');
it(`should import ${sourceFile.slice(sliceFrom)} directly without issue`, () => {
execSync(`./node_modules/.bin/ts-node -e "require('${sourceFile}')"`);
});
}
});

0 comments on commit 1b15074

Please sign in to comment.