diff options
| author | sanine <sanine.not@pm.me> | 2022-05-24 23:40:16 -0500 | 
|---|---|---|
| committer | sanine <sanine.not@pm.me> | 2022-05-24 23:40:16 -0500 | 
| commit | 2f2ab5149701243647a5f8d60dc9f771e45b2a5a (patch) | |
| tree | 5d11d0ede864155ebcca90cc9d5fede6c4acfedc /test.js | |
| parent | 550b5a5a626c05e93dd5aafbed9f7b6bb62807e9 (diff) | |
add hacky frameworkless unit testing
Diffstat (limited to 'test.js')
| -rw-r--r-- | test.js | 22 | 
1 files changed, 22 insertions, 0 deletions
| @@ -0,0 +1,22 @@ +import fs from 'node:fs'; +import { execSync } from 'node:child_process'; + +function recursiveScanDir(path, f) +{ +	let dirs = []; +	for (let dirent of fs.readdirSync(path, { withFileTypes: true })) { +		if (dirent.isDirectory()) dirs.push(`${path}/${dirent.name}`); +		else f(`${path}/${dirent.name}`); +	} +	for (let dir of dirs) { +		recursiveScanDir(dir, f); +	} +} + +recursiveScanDir('./modules', fname => { +	if (fname.endsWith('.test.js')) { +		console.log(`======== ${fname} ========`); +		execSync(`node ${fname}`, { stdio: 'inherit' }); +		console.log(''); +	} +}); | 
