Download src/scripts/run-tests.js from HonzaH/Letschat: direct link, hf CLI and curl.
- Browser
- Download file 1.27 kB
-
https://huggingface.co/spaces/HonzaH/Letschat/resolve/main/src/scripts/run-tests.js
- Command line
-
hf download hf://spaces/HonzaH/Letschat/src/scripts/run-tests.js
-
curl -L -o run-tests.js https://huggingface.co/spaces/HonzaH/Letschat/resolve/main/src/scripts/run-tests.js
1.27 kB
| // Lightweight test runner (Node) - uses ts-node and module-alias to load TS modules with path aliases | |
| require('module-alias/register') | |
| require('ts-node').register({ transpileOnly: true }) | |
| const path = require('path') | |
| const fs = require('fs') | |
| const tsconfig = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), 'tsconfig.json'), 'utf8')) | |
| const baseUrl = tsconfig.compilerOptions && tsconfig.compilerOptions.baseUrl ? path.resolve(process.cwd(), tsconfig.compilerOptions.baseUrl) : path.resolve(process.cwd(), 'src') | |
| const paths = tsconfig.compilerOptions && tsconfig.compilerOptions.paths ? tsconfig.compilerOptions.paths : { '*': ['./src/*'] } | |
| try { require('tsconfig-paths').register({ baseUrl, paths }) } catch(e) { /* best-effort */ } | |
| const assert = require('assert') | |
| const codes = require('lib/codes') | |
| (async () => { | |
| try { | |
| console.log('Running runtime tests (JS runner)') | |
| const c = codes.generateCode() | |
| console.log('Generated code:', c) | |
| assert.strictEqual(typeof c, 'string') | |
| assert.strictEqual(c.length, 5) | |
| assert.strictEqual(codes.validateCodeFormat(c), true) | |
| console.log('All tests passed') | |
| process.exit(0) | |
| } catch (err) { | |
| console.error('Tests failed', err) | |
| process.exit(1) | |
| } | |
| })() | |