summaryrefslogtreecommitdiff
path: root/packages/webapi/run/test.setup.js
blob: 6998a43bd3d773d1aeae5a23692accb1d1e9572b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { fileURLToPath } from 'url'

export { strict as assert } from 'assert'

export const pathFrom = (...args) =>
	fileURLToPath(args.reduce((url, bit) => new URL(bit, url), new URL('file:')))

export const test = async (setup) => {
	console.log(`Testing Node ${process.version}:`)
	console.log('')

	for (const test of setup()) {
		try {
			console.log(`- ${test.name}`)

			await test.test()
		} catch (error) {
			console.error(error)

			process.exit(1)
		}
	}

	console.log('')
	console.log('Pass!')
	console.log('')

	process.exit(0)
}