Files
monkey-ai-web/test/unit/test-discovery.test.js
T

63 lines
2.0 KiB
JavaScript

/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import assert from 'node:assert/strict';
import test from 'node:test';
import { mkdtemp, mkdir, writeFile, rm } from 'node:fs/promises';
import os from 'node:os';
import path from 'node:path';
import { findUnitTests } from '../../scripts/test.mjs';
test('unit discovery includes source and maintained suites and excludes evidence scripts', async () => {
const root = await mkdtemp(path.join(os.tmpdir(), 'monkey-unit-discovery-'));
try {
for (const name of [
'src/nested',
'tests/helpers',
'test/unit',
'report',
'logs',
'e2e',
])
await mkdir(path.join(root, name), { recursive: true });
for (const name of [
'src/nested/model.test.js',
'tests/legacy.test.js',
'test/unit/new.test.js',
'tests/helpers/loader.js',
'report/prototype-test.mjs',
'report/contracts.test.mjs',
'logs/output.test.js',
'e2e/page.spec.js',
])
await writeFile(path.join(root, name), '');
const files = await findUnitTests(root);
assert.deepEqual(
files.map((file) => path.relative(root, file).replaceAll('\\', '/')),
[
'src/nested/model.test.js',
'test/unit/new.test.js',
'tests/legacy.test.js',
],
);
} finally {
await rm(root, { recursive: true, force: true });
}
});