Skip to content

Commit 682474d

Browse files
test: execute installed CLI on real Git repository
1 parent 61862f1 commit 682474d

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

global-template/docgen/test/git-inventory-regression.test.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { projectPaths, writeJson } from '../lib/core.mjs';
1111
const testDir = path.dirname(fileURLToPath(import.meta.url));
1212
const engineRoot = path.resolve(testDir, '..');
1313
const repositoryRoot = path.resolve(engineRoot, '..', '..');
14+
const misspelledBoolean = ['Bole', 'an'].join('');
1415

1516
function fixture() {
1617
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'docgen-git-inventory-'));
@@ -66,12 +67,14 @@ test('installed launcher indexes a real Git repository', () => {
6667
encoding: 'utf8',
6768
env: { ...process.env, DOCGEN_PROGRESS: '0' }
6869
});
70+
const combinedOutput = `${run.stdout}\n${run.stderr}`;
6971
assert.equal(run.status, 0, `INDEX STDERR:\n${run.stderr}\nINDEX STDOUT:\n${run.stdout}`);
70-
assert.doesNotMatch(`${run.stdout}\n${run.stderr}`, /Bolean is not defined/);
72+
assert(!combinedOutput.includes(`${misspelledBoolean} is not defined`));
7173
assert(fs.existsSync(path.join(root, '.docgen', 'index', 'semantic.db')));
7274
});
7375

7476
test('shipped JavaScript contains no misspelled Boolean global', () => {
77+
const pattern = new RegExp(`\\b${misspelledBoolean}\\b`);
7578
const stack = [engineRoot];
7679
const offenders = [];
7780
while (stack.length) {
@@ -80,7 +83,7 @@ test('shipped JavaScript contains no misspelled Boolean global', () => {
8083
if (['node_modules', '.git'].includes(entry.name)) continue;
8184
const file = path.join(dir, entry.name);
8285
if (entry.isDirectory()) stack.push(file);
83-
else if (/\.(?:mjs|js|cjs)$/.test(entry.name) && /\bBolean\b/.test(fs.readFileSync(file, 'utf8'))) {
86+
else if (/\.(?:mjs|js|cjs)$/.test(entry.name) && pattern.test(fs.readFileSync(file, 'utf8'))) {
8487
offenders.push(path.relative(engineRoot, file));
8588
}
8689
}

0 commit comments

Comments
 (0)