2020-07-16 15:10:54 +00:00
|
|
|
import consola from 'consola'
|
2021-11-03 17:46:49 +00:00
|
|
|
import { isWindows } from 'std-env'
|
2020-07-16 15:10:54 +00:00
|
|
|
import exit from 'exit'
|
|
|
|
|
2021-11-03 17:46:49 +00:00
|
|
|
describe.win = isWindows ? describe : describe.skip
|
|
|
|
test.win = isWindows ? test : test.skip
|
2020-07-16 15:10:54 +00:00
|
|
|
|
2021-11-03 17:46:49 +00:00
|
|
|
describe.posix = !isWindows ? describe : describe.skip
|
|
|
|
test.posix = !isWindows ? test : test.skip
|
2020-07-16 15:10:54 +00:00
|
|
|
|
|
|
|
jest.setTimeout(60000)
|
|
|
|
|
|
|
|
consola.mockTypes(() => jest.fn())
|
|
|
|
|
|
|
|
function errorTrap (error) {
|
|
|
|
process.stderr.write('\n' + error.stack + '\n')
|
|
|
|
exit(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
process.on('unhandledRejection', errorTrap)
|
|
|
|
process.on('uncaughtException', errorTrap)
|
2020-12-22 17:07:50 +00:00
|
|
|
|
|
|
|
expect.extend({
|
|
|
|
toBePath (received, posixPath, winPath) {
|
2021-11-03 17:46:49 +00:00
|
|
|
const expectedPath = isWindows ? winPath : posixPath
|
2020-12-22 17:07:50 +00:00
|
|
|
const pass = received === expectedPath
|
|
|
|
return {
|
|
|
|
pass,
|
|
|
|
message: () =>
|
|
|
|
`expected path ${received} to be ${expectedPath}`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|