31 lines
756 B
JavaScript
31 lines
756 B
JavaScript
import path from 'node:path'
|
|
import { walkDir } from './walkDir.js'
|
|
import { summaryreporter, errorreporter, totalreporter } from 'metaltest'
|
|
|
|
const suite = async (folder = '.') => {
|
|
const fileIgnored = []
|
|
|
|
const total = totalreporter()
|
|
|
|
for await (const file of walkDir(folder, ['node_modules', '.git'])) {
|
|
if (!file.endsWith('.test.js')) continue
|
|
|
|
const module = path.resolve(folder, file)
|
|
const { test } = await import(module)
|
|
|
|
if (test === undefined) {
|
|
fileIgnored.push(file)
|
|
continue
|
|
}
|
|
|
|
await test.run(summaryreporter(), errorreporter(), total)
|
|
}
|
|
|
|
for (const file of fileIgnored) {
|
|
console.log(`The file ${file} doesn't export the metaltest object`)
|
|
}
|
|
|
|
console.log(total.msg())
|
|
}
|
|
|
|
export { suite } |