Skip to content

Commit 67a2e07

Browse files
committed
fix more runner UTs
1 parent f078caa commit 67a2e07

File tree

9 files changed

+54
-40
lines changed

9 files changed

+54
-40
lines changed

lib/command/configMigrate.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { mkdirp } from 'mkdirp'
55
import path from 'path'
66
import util from 'util'
77

8-
import { print, success, error } from '../output.js'
8+
import output from '../output.js'
9+
const { print, success, error } = output
910
import { fileExists } from '../utils.js'
1011
import { getTestRoot } from './utils.js'
1112

lib/command/init.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import path from 'path'
66
import { inspect } from 'util'
77
import spawn from 'cross-spawn'
88

9-
import { print, success, error } from '../output.js'
9+
import output from '../output.js'
10+
const { print, success, error } = output
1011
import { fileExists, beautify, installedLocally } from '../utils.js'
1112
import { getTestRoot } from './utils.js'
1213
import generateDefinitions from './definitions.js'

lib/steps.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import StepConfig from './step/config.js'
2-
import Section from './step/section.js'
2+
import SectionClass from './step/section.js'
33
function stepOpts(opts = {}) {
44
return new StepConfig(opts)
55
}
@@ -14,11 +14,11 @@ function stepRetry(retry) {
1414

1515
function section(name) {
1616
if (!name) return endSection()
17-
return new Section(name).start()
17+
return new SectionClass(name).start()
1818
}
1919

2020
function endSection() {
21-
return Section.current().end()
21+
return SectionClass.current().end()
2222
}
2323

2424
// Section function to be added here
@@ -48,3 +48,7 @@ const step = {
4848
}
4949

5050
export default step
51+
52+
// Named exports for ESM compatibility
53+
export const Section = step.Section
54+
export const EndSection = step.EndSection
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import Helper from '../../../../../lib/helper.js'
2+
13
class CustomHelper extends Helper {
24
act() {
35
this.debug(JSON.stringify(arguments))
46
}
57
}
68

7-
module.exports = CustomHelper
9+
export default CustomHelper

test/data/sandbox/configs/step-sections/userPage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { I } = inject()
22

3-
module.exports = {
3+
export default {
44
actOnPage: () => {
55
I.act('actOnPage')
66
I.act('see on this page')
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
1+
import Helper from '../../../../../lib/helper.js'
2+
13
function sleep(ms) {
2-
return new Promise((resolve) => {
3-
setTimeout(resolve, ms);
4-
});
4+
return new Promise(resolve => {
5+
setTimeout(resolve, ms)
6+
})
57
}
68

79
class CustomHelper extends Helper {
810
exceededByTimeout(ms) {
9-
return sleep(ms);
11+
return sleep(ms)
1012
}
1113

1214
waitForSleep(ms) {
13-
return sleep(ms);
15+
return sleep(ms)
1416
}
1517

1618
statefulSleep(ms) {
17-
this.fraction = ++this.fraction || 1;
18-
return sleep(ms - 500 * this.fraction);
19+
this.fraction = ++this.fraction || 1
20+
return sleep(ms - 500 * this.fraction)
1921
}
2022

2123
waitTadLonger(ms) {
22-
return sleep(ms);
24+
return sleep(ms)
2325
}
2426

2527
waitTadShorter(ms) {
26-
return sleep(ms);
28+
return sleep(ms)
2729
}
2830
}
2931

30-
module.exports = CustomHelper;
32+
export default CustomHelper
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
const given = when = then = global.codeceptjs.container.plugins('commentStep');
2-
const { I } = inject();
1+
const { I } = inject()
32

4-
Feature('Steps');
3+
Feature('Steps')
54

65
Scenario('Default command timeout', ({ I }) => {
7-
I.exceededByTimeout(1500);
8-
});
6+
I.exceededByTimeout(1500)
7+
})
98

109
Scenario('Wait command timeout', ({ I }) => {
11-
I.waitForSleep(1500);
12-
});
10+
I.waitForSleep(1500)
11+
})
1312

1413
Scenario('Rerun sleep', ({ I }) => {
15-
I.retry(2).statefulSleep(2250);
16-
});
14+
I.retry(2).statefulSleep(2250)
15+
})
1716

1817
Scenario('Wait with longer timeout', ({ I }) => {
19-
I.waitTadLonger(750);
20-
});
18+
I.waitTadLonger(750)
19+
})
2120

2221
Scenario('Wait with shorter timeout', ({ I }) => {
23-
I.waitTadShorter(750);
24-
});
22+
I.waitTadShorter(750)
23+
})
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// const Helper = require('../../lib/helper');
1+
import Helper from '../../../../../lib/helper.js'
22

33
class CustomHelper extends Helper {
44
shouldDoSomething(s) {}
55

66
fail() {
7-
throw new Error('Failed from helper');
7+
throw new Error('Failed from helper')
88
}
99
}
1010

11-
export default CustomHelper;
11+
export default CustomHelper

test/runner/init_test.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
import chai from 'chai';
2-
chai.should();
3-
import { DOWN, ENTER } from 'inquirer-test';
4-
import path from 'path';
5-
import { fileURLToPath } from 'url';
6-
const __filename = fileURLToPath(import.meta.url);
7-
const __dirname = path.dirname(__filename);
1+
import chai from 'chai'
2+
chai.should()
3+
import { DOWN, ENTER } from 'inquirer-test'
4+
import inquirerTest from 'inquirer-test'
5+
import path from 'path'
6+
import fs from 'fs'
7+
import { mkdirp } from 'mkdirp'
8+
import { fileURLToPath } from 'url'
9+
const __filename = fileURLToPath(import.meta.url)
10+
const __dirname = path.dirname(__filename)
11+
12+
const run = inquirerTest
813

914
const runner = path.join(__dirname, '../../bin/codecept.js')
1015
const codecept_dir = path.join(__dirname, '/../data/sandbox/configs/init')

0 commit comments

Comments
 (0)