|
1 |
| -import { Envelope, TestStepResultStatus, IdGenerator } from '@cucumber/messages' |
2 |
| -import fs from 'mz/fs' |
3 |
| -import path from 'path' |
4 |
| -import { reindent } from 'reindent-template-literals' |
5 |
| -import { PassThrough } from 'stream' |
| 1 | +import { Envelope, TestStepResultStatus } from '@cucumber/messages' |
6 | 2 | import { expect } from 'chai'
|
7 | 3 | import { runCucumber } from './run_cucumber'
|
8 | 4 | import { IRunEnvironment } from './types'
|
9 | 5 | import { loadSupport } from './load_support'
|
10 | 6 | import { loadConfiguration } from './load_configuration'
|
11 |
| - |
12 |
| -const newId = IdGenerator.uuid() |
13 |
| - |
14 |
| -async function setupEnvironment(): Promise<Partial<IRunEnvironment>> { |
15 |
| - const cwd = path.join(__dirname, '..', '..', 'tmp', `runCucumber_${newId()}`) |
16 |
| - await fs.mkdir(path.join(cwd, 'features'), { recursive: true }) |
17 |
| - await fs.writeFile( |
18 |
| - path.join(cwd, 'features', 'test.feature'), |
19 |
| - reindent(`Feature: test fixture |
20 |
| - Scenario: one |
21 |
| - Given a step |
22 |
| - Then another step`) |
23 |
| - ) |
24 |
| - await fs.writeFile( |
25 |
| - path.join(cwd, 'features', 'steps.ts'), |
26 |
| - reindent(`import { Given, Then } from '../../../src' |
27 |
| - Given('a step', function () {}) |
28 |
| - Then('another step', function () {})`) |
29 |
| - ) |
30 |
| - await fs.writeFile( |
31 |
| - path.join(cwd, 'cucumber.mjs'), |
32 |
| - `export default {paths: ['features/test.feature'], requireModule: ['ts-node/register'], require: ['features/steps.ts']}` |
33 |
| - ) |
34 |
| - const stdout = new PassThrough() |
35 |
| - return { cwd, stdout } |
36 |
| -} |
37 |
| - |
38 |
| -async function teardownEnvironment(environment: IRunEnvironment) { |
39 |
| - await fs.rmdir(environment.cwd, { recursive: true }) |
40 |
| - environment.stdout.end() |
41 |
| -} |
| 7 | +import { setupEnvironment, teardownEnvironment } from './test_helpers' |
42 | 8 |
|
43 | 9 | describe('runCucumber', () => {
|
44 | 10 | describe('preloading support code', () => {
|
|
0 commit comments