|
|
| 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) { }
|
| 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)
|
| }
|
| })()
|
|
|