Skip to content

Commit bca1d6b

Browse files
committed
test(typescript): cover explicit tsx esm step paths
1 parent 5927927 commit bca1d6b

2 files changed

Lines changed: 28 additions & 19 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { config as baseConfig } from './codecept.conf.js'
2+
3+
export const config = {
4+
...baseConfig,
5+
require: ['tsx/esm'],
6+
name: 'typescript-step-paths-esm',
7+
}

test/runner/typescript_step_paths_test.js

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,25 @@ const runner = path.join(__dirname, '../../bin/codecept.js')
99
const codeceptDir = path.join(__dirname, '../data/sandbox/typescript-step-paths')
1010

1111
describe('TypeScript step paths', () => {
12-
it('maps included page object steps back to their source file', done => {
13-
execFile(
14-
process.execPath,
15-
[runner, 'run', '--config', path.join(codeceptDir, 'codecept.conf.js')],
16-
{ cwd: codeceptDir, env: { ...process.env, FORCE_COLOR: '0' } },
17-
(err, stdout) => {
18-
try {
19-
expect(err).toBeTruthy()
20-
expect(stdout).toContain('Scenario Steps:')
21-
expect(stdout).toMatch(/at Object\.open \(\.\/pages\/fooPage\.ts:\d+:\d+\)/)
22-
expect(stdout).not.toContain('.temp.mjs')
23-
expect(stdout).not.toContain('file://./pages/fooPage.ts')
24-
done()
25-
} catch (error) {
26-
done(error)
27-
}
28-
},
29-
)
30-
})
12+
for (const configFile of ['codecept.conf.js', 'codecept.esm.conf.js']) {
13+
it(`maps included page object steps back to their source file with ${configFile}`, done => {
14+
execFile(
15+
process.execPath,
16+
[runner, 'run', '--config', path.join(codeceptDir, configFile)],
17+
{ cwd: codeceptDir, env: { ...process.env, FORCE_COLOR: '0' } },
18+
(err, stdout) => {
19+
try {
20+
expect(err).toBeTruthy()
21+
expect(stdout).toContain('Scenario Steps:')
22+
expect(stdout).toMatch(/at Object\.open \(\.\/pages\/fooPage\.ts:\d+:\d+\)/)
23+
expect(stdout).not.toContain('.temp.mjs')
24+
expect(stdout).not.toContain('file://./pages/fooPage.ts')
25+
done()
26+
} catch (error) {
27+
done(error)
28+
}
29+
},
30+
)
31+
})
32+
}
3133
})

0 commit comments

Comments
 (0)