Marc Cataford
912261443a
* refactor: build context and run tests after gathering facts * test: update integration test to not check for case collection * refactor: further cleanup * refactor: leftover log statements * refactor: further cleaning * refactor: no more collector
53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
import assert from 'assert'
|
|
import { promises as fs } from 'fs'
|
|
import util from 'util'
|
|
import childProcess from 'child_process'
|
|
|
|
const exec = util.promisify(childProcess.exec)
|
|
|
|
const TEST_ID = "requires-ts-node-for-ts-tests"
|
|
const TEST_DIRECTORY = `integration-test-${TEST_ID}`
|
|
|
|
const execOptions = { cwd: TEST_DIRECTORY }
|
|
|
|
async function setUp() {
|
|
await fs.mkdir(TEST_DIRECTORY)
|
|
await fs.writeFile(`${TEST_DIRECTORY}/package.json`, JSON.stringify({}))
|
|
await exec('touch yarn.lock', execOptions)
|
|
await exec('yarn add ../package.tgz', execOptions)
|
|
}
|
|
|
|
async function tearDown() {
|
|
await fs.rm(TEST_DIRECTORY, { recursive: true, force: true })
|
|
}
|
|
|
|
/*
|
|
* The runner skips Typescript files if the --ts flag is not used.
|
|
* A notice is printed about the skipped files.
|
|
*/
|
|
async function requires_ts_node_for_ts_tests() {
|
|
try {
|
|
await setUp()
|
|
|
|
await exec('touch sample.test.ts', execOptions)
|
|
const processOut = await exec('womm .', execOptions)
|
|
|
|
const stdout = processOut.stdout
|
|
|
|
assert.ok(stdout.includes('sample.test.ts is not supported without --ts and will be ignored'), 'Unsupported test notice not found')
|
|
assert.ok(stdout.includes('Collected 0 test files'), 'Did not find notice of no test collected')
|
|
} catch(e) {
|
|
await tearDown()
|
|
console.log(e)
|
|
assert.fail(`[FAILED] ${TEST_ID}`)
|
|
}
|
|
|
|
await tearDown()
|
|
|
|
console.log(`[PASS] ${TEST_ID}`)
|
|
}
|
|
|
|
requires_ts_node_for_ts_tests().catch((e) => {
|
|
console.error(e)
|
|
process.exit(1)
|
|
})
|