Skip to content

Commit 7cb26c7

Browse files
committed
fix tests
1 parent 0601089 commit 7cb26c7

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

bin/codecept.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import * as runMultiple from '../lib/command/run-multiple.js';
1818
import { runRerun } from '../lib/command/run-rerun.js';
1919
import * as dryRun from '../lib/command/dryRun.js';
2020
import * as info from '../lib/command/info.js';
21+
import { heal } from "../lib/command/generate.js";
2122

2223
const program = new Command();
2324

@@ -141,7 +142,7 @@ program.command('generate:helper [path]')
141142
program.command('generate:heal [path]')
142143
.alias('gr')
143144
.description('Generates basic heal recipes')
144-
.action(errorHandler(require('../lib/command/generate').heal));
145+
.action(errorHandler(heal));
145146

146147
program.command('run [test]')
147148
.description('Executes tests')

lib/codecept.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import session0 from './session.js';
2222

2323
import data from './data/table.js';
2424

25-
import * as Build from './locator.js';
25+
import Locator from './locator.js';
2626

2727
import secret from './secret.js';
2828

@@ -114,7 +114,7 @@ export default class Codecept {
114114
global.within = within0;
115115
global.session = session0;
116116
global.DataTable = data;
117-
global.locate = locator => new Build(locator);
117+
global.locate = locator => new Locator(locator);
118118
global.inject = container.support;
119119
global.share = container.share;
120120
global.secret = secret;

lib/command/generate.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import path from 'path';
66
import {
77
fileExists, ucfirst, lcfirst, beautify,
88
} from '../utils.js';
9-
import * as output from '../output.js';
9+
import { output } from '../output.js';
1010
import generateDefinitions from './definitions.js';
1111
import {
1212
getConfig, getTestRoot, safeFileWrite, readConfig,
1313
} from './utils.js';
14+
import container from '../container.js';
15+
import { __dirname } from '../dirname.js';
1416

1517
let extension = 'js';
1618

@@ -57,7 +59,6 @@ export const test = function (genPath) {
5759
if (!fileExists(dir)) mkdirp.sync(dir);
5860
let testContent = testTemplate.replace('{{feature}}', result.feature);
5961

60-
const container = require('../container.js');
6162
container.create(config, {});
6263
// translate scenario test
6364
if (container.translation().loaded) {
@@ -259,9 +260,9 @@ helpers: {
259260
});
260261
};
261262

262-
const healTemplate = fs.readFileSync(path.join(__dirname, '../template/heal.js'), 'utf8').toString();
263+
const healTemplate = fs.readFileSync(path.join(__dirname, '/template/heal.js'), 'utf8').toString();
263264

264-
module.exports.heal = function (genPath) {
265+
export function heal(genPath) {
265266
const testsPath = getTestRoot(genPath);
266267

267268
let configFile = path.join(testsPath, `codecept.conf.${extension}`);
@@ -279,7 +280,7 @@ module.exports.heal = function (genPath) {
279280
require('./heal')
280281
281282
exports.config = {
282-
// ...
283+
// ...
283284
plugins: {
284285
heal: {
285286
enabled: true

lib/container.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ let container = {
3232
/**
3333
* Dependency Injection Container
3434
*/
35-
export default class Container {
35+
class Container {
3636
/**
3737
* Create container with all required helpers and support objects
3838
*
@@ -157,6 +157,8 @@ export default class Container {
157157
}
158158
}
159159

160+
export default Container;
161+
160162
function createHelpers(config) {
161163
const helpers = {};
162164
let moduleName;

lib/plugin/coverage.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import debugModule from 'debug';
1+
import debug from 'debug';
22
import { CoverageReport } from 'monocart-coverage-reports';
3-
import Container from '../container.js';
3+
import container from '../container.js';
44
import recorder from '../recorder.js';
55
import * as event from '../event.js';
66
import * as output from '../output.js';
@@ -93,7 +93,8 @@ const v8CoverageHelpers = {
9393
export default function (config) {
9494
config = deepMerge(defaultConfig, config);
9595
if (config.debug) config.logging = 'debug';
96-
const helpers = Container.helpers();
96+
const helpers = container.helpers();
97+
console.log(helpers);
9798
let coverageRunning = false;
9899

99100
const v8Names = Object.keys(v8CoverageHelpers);
@@ -105,7 +106,7 @@ export default function (config) {
105106
}
106107

107108
config.name = `${config.name} - in ${helperName}`;
108-
const debug = debugModule(`codeceptjs:plugin:${helperName.toLowerCase()}Coverage`);
109+
const logger = debug(`codeceptjs:plugin:${helperName.toLowerCase()}Coverage`);
109110

110111
const helper = helpers[helperName];
111112
const v8Helper = v8CoverageHelpers[helperName];
@@ -132,7 +133,7 @@ export default function (config) {
132133
return;
133134
}
134135
coverageRunning = true;
135-
debug('--> starting coverage <--');
136+
logger('--> starting coverage <--');
136137
await v8Helper.startCoverage(helper.page);
137138
}, true);
138139
});
@@ -147,7 +148,7 @@ export default function (config) {
147148
return;
148149
}
149150
coverageRunning = false;
150-
debug('--> stopping coverage <--');
151+
logger('--> stopping coverage <--');
151152
await v8Helper.takeCoverage(helper.page, coverageReport);
152153
}, true);
153154
});

test/acceptance/codecept.Playwright.coverage.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import TestHelper from '../support/TestHelper.js';
22

3-
module.exports.config = {
3+
const config = {
44
tests: './*_test.js',
55
timeout: 10000,
66
output: './output',
@@ -16,13 +16,6 @@ module.exports.config = {
1616
ignoreHTTPSErrors: true,
1717
},
1818
},
19-
JSONResponse: {
20-
requestHelper: 'Playwright',
21-
},
22-
ScreenshotSessionHelper: {
23-
require: '../support/ScreenshotSessionHelper.js',
24-
outputPath: 'test/acceptance/output',
25-
},
2619
},
2720
include: {},
2821
bootstrap: false,
@@ -49,3 +42,5 @@ module.exports.config = {
4942
steps: ['./gherkin/steps.js'],
5043
},
5144
};
45+
46+
exports.config = config;

0 commit comments

Comments
 (0)