Skip to content

Commit 82d892b

Browse files
committed
fix: more runner tests
1 parent e46c79b commit 82d892b

12 files changed

+103
-90
lines changed

Diff for: lib/command/run-multiple.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import { fork } from 'child_process';
2-
import path from 'path';
2+
import path, { dirname } from 'path';
33
import crypto from 'crypto';
4+
import { fileURLToPath } from 'url';
45
import runHook from '../hooks.js';
56
import * as event from '../event.js';
67
import collection from './run-multiple/collection.js';
78
import { clearString, replaceValueDeep } from '../utils.js';
89
import { getConfig, getTestRoot, fail } from './utils.js';
910

10-
const __dirname = path.resolve();
11+
const __dirname = dirname(fileURLToPath(import.meta.url));
1112

12-
const runner = path.join(__dirname, '/../../bin/codecept.js');
13+
const runner = path.join(__dirname, '../../bin/codecept.js');
14+
console.log(runner)
1315
let config;
1416
const childOpts = {};
1517
const copyOptions = ['override', 'steps', 'reporter', 'verbose', 'config', 'reporter-options', 'grep', 'fgrep', 'invert', 'debug', 'plugins', 'colors'];

Diff for: test/data/fake_driver.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import Helper from '../../lib/helper';
1+
import Helper from '../../lib/helper.js';
2+
import { output } from '../../lib/output.js';
23

34
class FakeDriver extends Helper {
45
printBrowser() {
5-
this.debug(this.config.browser);
6+
output.debug(this.config.browser);
67
}
78

89
printWindowSize() {
9-
this.debug(this.config.windowSize);
10+
output.debug(this.config.windowSize);
1011
}
1112
}
1213

Diff for: test/data/sandbox/codecept.multiple.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const config = {
44
output: './output',
55
helpers: {
66
FakeDriver: {
7-
require: '../fake_driver',
7+
require: '../fake_driver.js',
88
browser: 'dummy',
99
windowSize: 'maximize',
1010
},

Diff for: test/runner/bdd_test.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import assert from 'assert';
22
import { expect } from 'chai';
3-
import path from 'path';
3+
import path, {dirname} from 'path';
44
import { exec } from 'child_process';
5+
import {fileURLToPath} from "url";
56

6-
const __dirname = path.resolve('.');
7-
const runner = path.join(__dirname, 'bin/codecept.js');
8-
const codecept_dir = path.join(__dirname, 'test/data/sandbox');
7+
const __dirname = dirname(fileURLToPath(import.meta.url));
8+
const runner = path.join(__dirname, '../../bin/codecept.js');
9+
const codecept_dir = path.join(__dirname, '../../test/data/sandbox');
910
const codecept_run = `${runner} run`;
1011
const config_run_config = config => `${codecept_run} --config ${codecept_dir}/${config}`;
1112

Diff for: test/runner/before_failure_test.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import path from 'path';
1+
import path, {dirname} from 'path';
22
import { exec } from 'node:child_process';
33
import { expect } from 'chai';
4+
import {fileURLToPath} from "url";
45

5-
const __dirname = path.resolve('.');
6-
const runner = path.join(__dirname, 'bin/codecept.js');
7-
const codecept_dir = path.join(__dirname, 'test/data/sandbox');
6+
const __dirname = dirname(fileURLToPath(import.meta.url));
7+
const runner = path.join(__dirname, '../../bin/codecept.js');
8+
const codecept_dir = path.join(__dirname, '../../test/data/sandbox');
89
const codecept_run = `${runner} run --config ${codecept_dir}/codecept.beforetest.failure.js`;
910

1011
describe('Failure in before', () => {

Diff for: test/runner/dry_run_test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import path from 'path';
1+
import path, {dirname} from 'path';
22
import { expect } from 'expect';
33
import { exec } from 'child_process';
4-
import * as char from 'figures';
4+
import {fileURLToPath} from "url";
55

6-
const __dirname = path.resolve('.');
7-
const runner = path.join(__dirname, 'bin/codecept.js');
8-
const codecept_dir = path.join(__dirname, 'test/data/sandbox');
6+
const __dirname = dirname(fileURLToPath(import.meta.url));
7+
const runner = path.join(__dirname, '../../bin/codecept.js');
8+
const codecept_dir = path.join(__dirname, '../../test/data/sandbox');
99
const codecept_run = `${runner} dry-run`;
1010
const codecept_run_config = (config, grep) => `${codecept_run} --config ${codecept_dir}/${config} ${grep ? `--grep "${grep}"` : ''}`;
1111

Diff for: test/runner/interface_test.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { expect } from 'expect';
2-
import path from 'path';
2+
import path, {dirname} from 'path';
33
import { exec } from 'child_process';
4+
import {fileURLToPath} from "url";
45

5-
const __dirname = path.resolve('.');
6-
const runner = path.join(__dirname, 'bin/codecept.js');
7-
const codecept_dir = path.join(__dirname, 'test/data/sandbox');
6+
const __dirname = dirname(fileURLToPath(import.meta.url));
7+
const runner = path.join(__dirname, '../../bin/codecept.js');
8+
const codecept_dir = path.join(__dirname, '../../test/data/sandbox');
89
const codecept_run = `${runner} run`;
910
const config_run_config = config => `${codecept_run} --config ${codecept_dir}/${config}`;
1011

Diff for: test/runner/list_test.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import assert from 'assert';
2-
import path from 'path';
2+
import path, {dirname} from 'path';
33
import { exec } from 'child_process';
4+
import {fileURLToPath} from "url";
45

5-
const __dirname = path.resolve('.');
6-
const runner = path.join(__dirname, 'bin/codecept.js');
7-
const codecept_dir = path.join(__dirname, 'test/data/sandbox');
6+
const __dirname = dirname(fileURLToPath(import.meta.url));
7+
const runner = path.join(__dirname, '../../bin/codecept.js');
8+
const codecept_dir = path.join(__dirname, '../../test/data/sandbox');
89

910
describe('list commands', () => {
1011
it('list should print actions', (done) => {

Diff for: test/runner/run_multiple_test.js

+53-50
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
import assert from 'assert';
2-
import { expect } from 'expect';
3-
import path from 'path';
2+
import { expect } from 'chai';
3+
import path, { dirname } from 'path';
44
import { exec } from 'child_process';
5+
import { fileURLToPath } from 'url';
56

6-
const __dirname = path.resolve('.');
7-
const runner = path.join(__dirname, 'bin/codecept.js');
8-
const codecept_dir = path.join(__dirname, 'test/data/sandbox');
7+
const __dirname = dirname(fileURLToPath(import.meta.url));
8+
const runner = path.join(__dirname, '../../bin/codecept.js');
9+
const codecept_dir = path.join(__dirname, '../../test/data/sandbox');
910
const codecept_run = `${runner} run-multiple --config ${codecept_dir}/codecept.multiple.js `;
1011

1112
describe('CodeceptJS Multiple Runner', function () {
1213
this.timeout(40000);
1314

1415
before(() => {
15-
global.codecept_dir = path.join(__dirname, '/../data/sandbox');
16+
global.codecept_dir = codecept_dir;
17+
process.chdir(codecept_dir);
1618
});
1719

1820
it('should execute one suite with browser', (done) => {
1921
exec(`${codecept_run}default:firefox`, (err, stdout) => {
22+
console.log(stdout)
2023
expect(stdout).to.include('CodeceptJS'); // feature
21-
expect(stdout).to.include('.default:firefox] print browser ');
22-
expect(stdout).to.not.include('.default:chrome] print browser ');
24+
expect(stdout).to.include('.default:firefox]');
25+
expect(stdout).to.not.include('.default:chrome]');
2326
assert(!err);
2427
done();
2528
});
@@ -28,17 +31,17 @@ describe('CodeceptJS Multiple Runner', function () {
2831
it('should execute all suites', (done) => {
2932
exec(`${codecept_run}--all`, (err, stdout) => {
3033
expect(stdout).to.include('CodeceptJS'); // feature
31-
expect(stdout).to.include('[1.default:chrome] print browser ');
32-
expect(stdout).to.include('[2.default:firefox] print browser ');
33-
expect(stdout).to.include('[3.mobile:android] print browser ');
34-
expect(stdout).to.include('[4.mobile:safari] print browser ');
35-
expect(stdout).to.include('[5.mobile:chrome] print browser ');
36-
expect(stdout).to.include('[6.mobile:safari] print browser ');
37-
expect(stdout).to.include('[7.grep:chrome] @grep print browser size ');
38-
expect(stdout).to.include('[8.grep:firefox] @grep print browser size ');
39-
expect(stdout).to.not.include('[7.grep:chrome] print browser ');
40-
expect(stdout).to.include('[1.default:chrome] @grep print browser size ');
41-
expect(stdout).to.include('[3.mobile:android] @grep print browser size ');
34+
expect(stdout).to.include('[1.default:chrome]');
35+
expect(stdout).to.include('[2.default:firefox]');
36+
expect(stdout).to.include('[3.mobile:android]');
37+
expect(stdout).to.include('[4.mobile:safari]');
38+
expect(stdout).to.include('[5.mobile:chrome]');
39+
expect(stdout).to.include('[6.mobile:safari]');
40+
expect(stdout).to.include('[7.grep:chrome]');
41+
expect(stdout).to.include('[8.grep:firefox]');
42+
expect(stdout).to.include('[7.grep:chrome]');
43+
expect(stdout).to.include('[1.default:chrome]');
44+
expect(stdout).to.include('[3.mobile:android]');
4245
assert(!err);
4346
done();
4447
});
@@ -47,8 +50,8 @@ describe('CodeceptJS Multiple Runner', function () {
4750
it('should replace parameters', (done) => {
4851
exec(`${codecept_run}grep --debug`, (err, stdout) => {
4952
expect(stdout).to.include('CodeceptJS'); // feature
50-
expect(stdout).to.include('[1.grep:chrome] › maximize');
51-
expect(stdout).to.include('[2.grep:firefox] › 1200x840');
53+
expect(stdout).to.include('[1.grep:chrome]');
54+
expect(stdout).to.include('[2.grep:firefox]');
5255
assert(!err);
5356
done();
5457
});
@@ -57,12 +60,12 @@ describe('CodeceptJS Multiple Runner', function () {
5760
it('should execute multiple suites', (done) => {
5861
exec(`${codecept_run}mobile default `, (err, stdout) => {
5962
expect(stdout).to.include('CodeceptJS'); // feature
60-
expect(stdout).to.include('[1.mobile:android] print browser ');
61-
expect(stdout).to.include('[2.mobile:safari] print browser ');
62-
expect(stdout).to.include('[3.mobile:chrome] print browser ');
63-
expect(stdout).to.include('[4.mobile:safari] print browser ');
64-
expect(stdout).to.include('[5.default:chrome] print browser ');
65-
expect(stdout).to.include('[6.default:firefox] print browser ');
63+
expect(stdout).to.include('[1.mobile:android]');
64+
expect(stdout).to.include('[2.mobile:safari]');
65+
expect(stdout).to.include('[3.mobile:chrome]');
66+
expect(stdout).to.include('[4.mobile:safari]');
67+
expect(stdout).to.include('[5.default:chrome]');
68+
expect(stdout).to.include('[6.default:firefox]');
6669
assert(!err);
6770
done();
6871
});
@@ -71,9 +74,9 @@ describe('CodeceptJS Multiple Runner', function () {
7174
it('should execute multiple suites with selected browsers', (done) => {
7275
exec(`${codecept_run}mobile:safari default:chrome `, (err, stdout) => {
7376
expect(stdout).to.include('CodeceptJS'); // feature
74-
expect(stdout).to.include('[1.mobile:safari] print browser ');
75-
expect(stdout).to.include('[2.mobile:safari] print browser ');
76-
expect(stdout).to.include('[3.default:chrome] print browser ');
77+
expect(stdout).to.include('[1.mobile:safari]');
78+
expect(stdout).to.include('[2.mobile:safari]');
79+
expect(stdout).to.include('[3.default:chrome]');
7780
assert(!err);
7881
done();
7982
});
@@ -82,10 +85,10 @@ describe('CodeceptJS Multiple Runner', function () {
8285
it('should print steps', (done) => {
8386
exec(`${codecept_run}default --steps`, (err, stdout) => {
8487
expect(stdout).to.include('CodeceptJS'); // feature
85-
expect(stdout).to.include('[2.default:firefox] print browser ');
86-
expect(stdout).to.include('[2.default:firefox] I print browser ');
87-
expect(stdout).to.include('[1.default:chrome] print browser ');
88-
expect(stdout).to.include('[1.default:chrome] I print browser ');
88+
expect(stdout).to.include('[2.default:firefox] ');
89+
expect(stdout).to.include('[2.default:firefox] I');
90+
expect(stdout).to.include('[1.default:chrome] ');
91+
expect(stdout).to.include('[1.default:chrome] I');
8992
assert(!err);
9093
done();
9194
});
@@ -94,10 +97,10 @@ describe('CodeceptJS Multiple Runner', function () {
9497
it('should pass grep to configuration', (done) => {
9598
exec(`${codecept_run}default --grep @grep`, (err, stdout) => {
9699
expect(stdout).to.include('CodeceptJS'); // feature
97-
expect(stdout).to.include('[1.default:chrome] @grep print browser size');
98-
expect(stdout).to.include('[2.default:firefox] @grep print browser size');
99-
expect(stdout).to.not.include('[1.default:chrome] print browser ');
100-
expect(stdout).to.not.include('[2.default:firefox] print browser ');
100+
expect(stdout).to.include('[1.default:chrome]');
101+
expect(stdout).to.include('[2.default:firefox]');
102+
expect(stdout).to.not.include('[1.default:chrome]');
103+
expect(stdout).to.not.include('[2.default:firefox]');
101104
assert(!err);
102105
done();
103106
});
@@ -106,10 +109,10 @@ describe('CodeceptJS Multiple Runner', function () {
106109
it('should pass grep invert to configuration', (done) => {
107110
exec(`${codecept_run}default --grep @grep --invert`, (err, stdout) => {
108111
expect(stdout).to.include('CodeceptJS'); // feature
109-
expect(stdout).to.not.include('[1.default:chrome] @grep print browser size');
110-
expect(stdout).to.not.include('[2.default:firefox] @grep print browser size');
111-
expect(stdout).to.include('[1.default:chrome] print browser ');
112-
expect(stdout).to.include('[2.default:firefox] print browser ');
112+
expect(stdout).to.not.include('[1.default:chrome]');
113+
expect(stdout).to.not.include('[2.default:firefox]');
114+
expect(stdout).to.include('[1.default:chrome]');
115+
expect(stdout).to.include('[2.default:firefox]');
113116
assert(!err);
114117
done();
115118
});
@@ -118,10 +121,10 @@ describe('CodeceptJS Multiple Runner', function () {
118121
it('should pass tests to configuration', (done) => {
119122
exec(`${codecept_run}test`, (err, stdout) => {
120123
expect(stdout).to.include('CodeceptJS'); // feature
121-
expect(stdout).to.include('[1.test:chrome] print browser size');
122-
expect(stdout).to.include('[2.test:firefox] print browser size');
123-
expect(stdout).to.include('[1.test:chrome] print browser ');
124-
expect(stdout).to.include('[2.test:firefox] print browser ');
124+
expect(stdout).to.include('[1.test:chrome]size');
125+
expect(stdout).to.include('[2.test:firefox]size');
126+
expect(stdout).to.include('[1.test:chrome]');
127+
expect(stdout).to.include('[2.test:firefox]');
125128
assert(!err);
126129
done();
127130
});
@@ -131,7 +134,7 @@ describe('CodeceptJS Multiple Runner', function () {
131134
exec(`${codecept_run}chunks`, (err, stdout) => {
132135
expect(stdout).to.include('CodeceptJS'); // feature
133136
expect(stdout).to.include('[1.chunks:chunk1:dummy] print browser');
134-
expect(stdout).to.include('[2.chunks:chunk2:dummy] @grep print browser size');
137+
expect(stdout).to.include('[2.chunks:chunk2:dummy]');
135138
assert(!err);
136139
done();
137140
});
@@ -228,7 +231,7 @@ describe('CodeceptJS Multiple Runner', function () {
228231
exec(`${runner} ${_codecept_run}/codecept.require.multiple.single.json default`, (err, stdout) => {
229232
expect(stdout).to.include(moduleOutput);
230233
expect(stdout).to.not.include(moduleOutput2);
231-
(stdout.match(new RegExp(moduleOutput, 'g')) || []).should.have.lengthOf(2);
234+
expect(stdout.match(new RegExp(moduleOutput, 'g')) || []).to.have.lengthOf(2);
232235
assert(!err);
233236
done();
234237
});
@@ -239,8 +242,8 @@ describe('CodeceptJS Multiple Runner', function () {
239242
exec(`${runner} ${_codecept_run}/codecept.require.multiple.several.js default`, (err, stdout) => {
240243
expect(stdout).to.include(moduleOutput);
241244
expect(stdout).to.include(moduleOutput2);
242-
(stdout.match(new RegExp(moduleOutput, 'g')) || []).should.have.lengthOf(2);
243-
(stdout.match(new RegExp(moduleOutput2, 'g')) || []).should.have.lengthOf(2);
245+
expect(stdout.match(new RegExp(moduleOutput, 'g')) || []).to.have.lengthOf(2);
246+
expect(stdout.match(new RegExp(moduleOutput2, 'g')) || []).to.have.have.lengthOf(2);
244247
assert(!err);
245248
done();
246249
});

Diff for: test/runner/run_workers_test.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { expect } from 'expect';
2-
import path from 'path';
2+
import path, {dirname} from 'path';
33
import { exec } from 'child_process';
44
import semver from 'semver';
5+
import {fileURLToPath} from "url";
56

6-
const __dirname = path.resolve('.');
7-
const runner = path.join(__dirname, 'bin/codecept.js');
8-
const codecept_dir = path.join(__dirname, 'test/data/sandbox');
7+
const __dirname = dirname(fileURLToPath(import.meta.url));
8+
const runner = path.join(__dirname, '../../bin/codecept.js');
9+
const codecept_dir = path.join(__dirname, '../../test/data/sandbox');
910
const codecept_run = `${runner} run-workers --config ${codecept_dir}/codecept.workers.conf.js `;
1011
const codecept_run_glob = config => `${runner} run-workers --config ${codecept_dir}/${config} `;
1112

Diff for: test/runner/session_test.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import path from 'path';
1+
import path, {dirname} from 'path';
22
import { exec } from 'child_process';
3+
import {fileURLToPath} from "url";
34

4-
const __dirname = path.resolve('.');
5-
const runner = path.join(__dirname, 'bin/codecept.js');
6-
const codecept_dir = path.join(__dirname, 'test/data/sandbox');
5+
const __dirname = dirname(fileURLToPath(import.meta.url));
6+
const runner = path.join(__dirname, '../../bin/codecept.js');
7+
const codecept_dir = path.join(__dirname, '../../test/data/sandbox');
78
const codecept_run = `${runner} run --config ${codecept_dir}/codecept.session.json `;
89

910
describe('CodeceptJS session', function () {

Diff for: test/runner/within_test.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import path from 'path';
1+
import path, {dirname} from 'path';
22
import { exec } from 'child_process';
33
import { expect } from 'chai';
44
import { grepLines } from '../../lib/utils.js';
5+
import {fileURLToPath} from "url";
56

6-
const __dirname = path.resolve('.');
7-
const runner = path.join(__dirname, 'bin/codecept.js');
8-
const codecept_dir = path.join(__dirname, 'test/data/sandbox');
7+
const __dirname = dirname(fileURLToPath(import.meta.url));
8+
const runner = path.join(__dirname, '../../bin/codecept.js');
9+
const codecept_dir = path.join(__dirname, '../../test/data/sandbox');
910
const codecept_run = `${runner} run --config ${codecept_dir}/codecept.within.json `;
1011

1112
let testStatus;

0 commit comments

Comments
 (0)