-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: include original coordinates in support code library (#2197)
- Loading branch information
1 parent
c2227ed
commit 8b89a9c
Showing
6 changed files
with
76 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { IRunEnvironment } from './types' | ||
import path from 'path' | ||
import { loadSupport } from './load_support' | ||
import { loadConfiguration } from './load_configuration' | ||
import { expect } from 'chai' | ||
import { setupEnvironment, teardownEnvironment } from './test_helpers' | ||
|
||
describe('loadSupport', () => { | ||
let environment: IRunEnvironment | ||
beforeEach(async () => { | ||
environment = await setupEnvironment() | ||
}) | ||
afterEach(async () => teardownEnvironment(environment)) | ||
|
||
it('should include original paths in the returned support code library', async () => { | ||
const { runConfiguration } = await loadConfiguration({}, environment) | ||
const support = await loadSupport(runConfiguration, environment) | ||
|
||
expect(support.originalCoordinates).to.deep.eq({ | ||
requireModules: ['ts-node/register'], | ||
requirePaths: [path.join(environment.cwd, 'features', 'steps.ts')], | ||
importPaths: [], | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { IRunEnvironment } from './types' | ||
import path from 'path' | ||
import fs from 'mz/fs' | ||
import { reindent } from 'reindent-template-literals' | ||
import { PassThrough } from 'stream' | ||
import { IdGenerator } from '@cucumber/messages' | ||
|
||
const newId = IdGenerator.uuid() | ||
|
||
export async function setupEnvironment(): Promise<Partial<IRunEnvironment>> { | ||
const cwd = path.join(__dirname, '..', '..', 'tmp', `api_${newId()}`) | ||
await fs.mkdir(path.join(cwd, 'features'), { recursive: true }) | ||
await fs.writeFile( | ||
path.join(cwd, 'features', 'test.feature'), | ||
reindent(`Feature: test fixture | ||
Scenario: one | ||
Given a step | ||
Then another step`) | ||
) | ||
await fs.writeFile( | ||
path.join(cwd, 'features', 'steps.ts'), | ||
reindent(`import { Given, Then } from '../../../src' | ||
Given('a step', function () {}) | ||
Then('another step', function () {})`) | ||
) | ||
await fs.writeFile( | ||
path.join(cwd, 'cucumber.mjs'), | ||
`export default {paths: ['features/test.feature'], requireModule: ['ts-node/register'], require: ['features/steps.ts']}` | ||
) | ||
const stdout = new PassThrough() | ||
return { cwd, stdout } | ||
} | ||
|
||
export async function teardownEnvironment(environment: IRunEnvironment) { | ||
await fs.rmdir(environment.cwd, { recursive: true }) | ||
environment.stdout.end() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters