Skip to content

Commit 33ccd9b

Browse files
committed
fix: more tests
1 parent f535d49 commit 33ccd9b

File tree

105 files changed

+235
-223
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+235
-223
lines changed

docs/configuration.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,26 @@ CodeceptJS configuration is set in `codecept.conf.js` file.
99

1010
After running `codeceptjs init` it should be saved in test root.
1111

12-
| Name | Type | Description |
13-
| :------ | :------ | :------ |
14-
| `bootstrap?` | (() => `Promise`<`void`\>) \| `boolean` \| `string` | [Execute code before](https://codecept.io/bootstrap/) tests are run. Can be either JS module file or async function: ```bootstrap: async () => server.launch(), ``` or ```bootstrap: 'bootstrap.js', ``` |
15-
| `bootstrapAll?` | (() => `Promise`<`void`\>) \| `boolean` \| `string` | [Execute code before launching tests in parallel mode](https://codecept.io/bootstrap/#bootstrapall-teardownall) |
16-
| `gherkin?` | { `features`: `string` \| `string`[] ; `steps`: `string`[] } | Enable [BDD features](https://codecept.io/bdd/#configuration). Sample configuration: ```gherkin: { features: "./features/*.feature", steps: ["./step_definitions/steps.js"] } ``` |
17-
| `gherkin.features` | `string` \| `string`[] | load feature files by pattern. Multiple patterns can be specified as array |
18-
| `gherkin.steps` | `string`[] | load step definitions from JS files |
19-
| `grep?` | `string` | Pattern to filter tests by name. This option is useful if you plan to use multiple configs for different environments. To execute only tests with @firefox tag use ```grep: '@firefox' ``` |
20-
| `helpers?` | {} | Enable and configure helpers: ```helpers: { Playwright: { url: 'https://mysite.com', browser: 'firefox' } } ``` |
21-
| `include?` | `any` | Include page objects to access them via dependency injection ```I: "./custom_steps.js", loginPage: "./pages/Login.js", User: "./pages/User.js", ``` Configured modules can be injected by name in a Scenario: ```Scenario('test', { I, loginPage, User }) ``` |
12+
| Name | Type | Description |
13+
| :------ | :------ |:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
14+
| `bootstrap?` | (() => `Promise`<`void`\>) \| `boolean` \| `string` | [Execute code before](https://codecept.io/bootstrap/) tests are run. Can be either JS module file or async function: ```bootstrap: async () => server.launch(), ``` or ```bootstrap: 'bootstrap.js', ``` |
15+
| `bootstrapAll?` | (() => `Promise`<`void`\>) \| `boolean` \| `string` | [Execute code before launching tests in parallel mode](https://codecept.io/bootstrap/#bootstrapall-teardownall) |
16+
| `gherkin?` | { `features`: `string` \| `string`[] ; `steps`: `string`[] } | Enable [BDD features](https://codecept.io/bdd/#configuration). Sample configuration: ```gherkin: { features: "./features/*.feature", steps: ["./step_definitions/steps.js"] } ``` |
17+
| `gherkin.features` | `string` \| `string`[] | load feature files by pattern. Multiple patterns can be specified as array |
18+
| `gherkin.steps` | `string`[] | load step definitions from JS files |
19+
| `grep?` | `string` | Pattern to filter tests by name. This option is useful if you plan to use multiple configs for different environments. To execute only tests with @firefox tag use ```grep: '@firefox' ``` |
20+
| `helpers?` | {} | Enable and configure helpers: ```helpers: { Playwright: { url: 'https://mysite.com', browser: 'firefox' } } ``` |
21+
| `include?` | `any` | Include page objects to access them via dependency injection ```I: "./custom_steps.js", loginPage: "./pages/Login.js", User: "./pages/User.js", ``` Configured modules can be injected by name in a Scenario: ```Scenario('test', { I, loginPage, User }) ``` |
2222
| `mocha?` | `any` | [Mocha test runner options](https://mochajs.org/#configuring-mocha-nodejs), additional [reporters](https://codecept.io/reports/#xml) can be configured here. Example: ```mocha: { "mocha-junit-reporter": { stdout: "./output/console.log", options: { mochaFile: "./output/result.xml", attachments: true //add screenshot for a failed test } } } ``` |
23-
| `noGlobals?` | `boolean` | Disable registering global functions (Before, Scenario, etc). Not recommended |
24-
| `output` | `string` | Where to store failure screenshots, artifacts, etc ```output: './output.js' ``` |
25-
| `plugins?` | `any` | Enable CodeceptJS plugins. Example: ```plugins: { autoDelay: { enabled: true } } ``` |
26-
| `require?` | `string`[] | [Require additional JS modules](https://codecept.io/configuration/#require) Example: ``` require: ["should"] ``` |
27-
| `teardown?` | (() => `Promise`<`void`\>) \| `boolean` \| `string` | [Execute code after tests](https://codecept.io/bootstrap/) finished. Can be either JS module file or async function: ```teardown: async () => server.stop(), ``` or ```teardown: 'teardown.js', ``` |
28-
| `teardownAll?` | (() => `Promise`<`void`\>) \| `boolean` \| `string` | [Execute JS code after finishing tests in parallel mode](https://codecept.io/bootstrap/#bootstrapall-teardownall) |
29-
| `tests` | `string` | Pattern to locate CodeceptJS tests. Allows to enter glob pattern or an Array<string> of patterns to match tests / test file names. For tests in JavaScript: ```tests: 'tests/**.test.js' ``` For tests in TypeScript: ```tests: 'tests/**.test.ts' ``` |
30-
| `timeout?` | `number` | Set default tests timeout in seconds. Tests will be killed on no response after timeout. ```timeout: 20, ``` |
31-
| `translation?` | `string` | Enable [localized test commands](https://codecept.io/translation/) |
23+
| `noGlobals?` | `boolean` | Disable registering global functions (Before, Scenario, etc). Not recommended |
24+
| `output` | `string` | Where to store failure screenshots, artifacts, etc ```output: './output' ``` |
25+
| `plugins?` | `any` | Enable CodeceptJS plugins. Example: ```plugins: { autoDelay: { enabled: true } } ``` |
26+
| `require?` | `string`[] | [Require additional JS modules](https://codecept.io/configuration/#require) Example: ``` require: ["should"] ``` |
27+
| `teardown?` | (() => `Promise`<`void`\>) \| `boolean` \| `string` | [Execute code after tests](https://codecept.io/bootstrap/) finished. Can be either JS module file or async function: ```teardown: async () => server.stop(), ``` or ```teardown: 'teardown.js', ``` |
28+
| `teardownAll?` | (() => `Promise`<`void`\>) \| `boolean` \| `string` | [Execute JS code after finishing tests in parallel mode](https://codecept.io/bootstrap/#bootstrapall-teardownall) |
29+
| `tests` | `string` | Pattern to locate CodeceptJS tests. Allows to enter glob pattern or an Array<string> of patterns to match tests / test file names. For tests in JavaScript: ```tests: 'tests/**.test.js' ``` For tests in TypeScript: ```tests: 'tests/**.test.ts' ``` |
30+
| `timeout?` | `number` | Set default tests timeout in seconds. Tests will be killed on no response after timeout. ```timeout: 20, ``` |
31+
| `translation?` | `string` | Enable [localized test commands](https://codecept.io/translation/) |
3232

3333

3434
## Require

examples/codecept.config.example.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ console.log(process.env.profile);
55
exports.config = {
66
tests: './*_test.js',
77
timeout: 10000,
8-
output: './output.js',
8+
output: './output',
99
helpers: {
1010
WebDriver: {
1111
url: 'http://localhost',

examples/codecept.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
exports.config = {
2-
output: './output.js',
2+
output: './output',
33
helpers: {
44
Playwright: {
55
url: 'http://github.com',

examples/selenoid-example/codecept.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
exports.config = {
22
tests: './*_test.js',
3-
output: './output.js',
3+
output: './output',
44
helpers: {
55
WebDriver: {
66
url: 'http://localhost',

lib/command/init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export default function (initPath) {
136136
},
137137
{
138138
name: 'output',
139-
default: './output.js',
139+
default: './output',
140140
message: 'Where should logs, screenshots, and reports to be stored?',
141141
},
142142
{

lib/command/run-workers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { tryOrDefault } from '../utils.js';
33

44
import * as output from '../output.js';
55
import * as event from '../event.js';
6-
import Workers from '../workers.js';
6+
import { Workers } from '../workers.js';
77
import { getMachineInfo } from './info.js';
88
import * as Codecept from '../codecept.js';
99

lib/command/run.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export default async function (test, options) {
1717
const configFile = options.config;
1818

1919
let config = getConfig(configFile);
20+
console.log(configFile)
21+
2022
if (options.override) {
2123
config = Config.append(JSON.parse(options.override));
2224
}

lib/config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import path from 'path';
33
import {
44
fileExists, isFile, deepMerge, deepClone,
55
} from './utils.js';
6+
import importSync from "import-sync";
67

78
const defaultConfig = {
89
output: './_output',
@@ -154,7 +155,8 @@ function loadConfigFile(configFile) {
154155

155156
// .conf.js config file
156157
if (extensionName === '.js' || extensionName === '.ts' || extensionName === '.cjs') {
157-
return Config.create(configFile.config);
158+
const { config } = importSync(configFile);
159+
return Config.create(config);
158160
}
159161

160162
// json config provided

lib/container.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import {
66
fileExists, isFunction, isAsyncFunction, deepMerge,
77
} from './utils.js';
88
import Translation from './translation.js';
9-
import MochaFactory from './mochaFactory.js';
9+
import { MochaFactory } from './mochaFactory.js';
1010
import recorder from './recorder.js';
1111
import * as event from './event.js';
12-
import WorkerStorage from './workerStorage.js';
12+
import * as WorkerStorage from './workerStorage.js';
1313
import { store } from './store.js';
1414

1515
import { actor } from './actor.js';
@@ -160,6 +160,7 @@ function createHelpers(config) {
160160
try {
161161
if (config[helperName].require) {
162162
if (config[helperName].require.startsWith('.')) {
163+
// @ts-ignore
163164
moduleName = path.resolve(global.codecept_dir, config[helperName].require); // custom helper
164165
} else {
165166
moduleName = config[helperName].require; // plugin helper
@@ -295,6 +296,7 @@ function createPlugins(config, options = {}) {
295296
if (config[pluginName].require) {
296297
module = config[pluginName].require;
297298
if (module.startsWith('.')) { // local
299+
// @ts-ignore
298300
module = path.resolve(global.codecept_dir, module); // custom plugin
299301
}
300302
} else {
@@ -317,7 +319,9 @@ function getSupportObject(config, name) {
317319
}
318320

319321
function loadGherkinSteps(paths) {
322+
// @ts-ignore
320323
global.Before = fn => event.dispatcher.on(event.test.started, fn);
324+
// @ts-ignore
321325
global.After = fn => event.dispatcher.on(event.test.finished, fn);
322326
global.Fail = fn => event.dispatcher.on(event.test.failed, fn);
323327

@@ -329,6 +333,7 @@ function loadGherkinSteps(paths) {
329333
loadSupportObject(path, `Step Definition from ${path}`);
330334
}
331335
} else {
336+
// @ts-ignore
332337
const folderPath = paths.startsWith('.') ? path.join(global.codecept_dir, paths) : '';
333338
if (folderPath !== '') {
334339
glob.sync(folderPath).forEach((file) => {
@@ -337,13 +342,16 @@ function loadGherkinSteps(paths) {
337342
}
338343
}
339344

345+
// @ts-ignore
340346
delete global.Before;
347+
// @ts-ignore
341348
delete global.After;
342349
delete global.Fail;
343350
}
344351

345352
function loadSupportObject(modulePath, supportObjectName) {
346353
if (modulePath.charAt(0) === '.') {
354+
// @ts-ignore
347355
modulePath = path.join(global.codecept_dir, modulePath);
348356
}
349357
try {
@@ -405,7 +413,7 @@ function getObjectMethods(obj) {
405413
const methodsSet = new Set();
406414
let protoObj = Reflect.getPrototypeOf(obj);
407415
do {
408-
if (protoObj.constructor.prototype !== Object.prototype) {
416+
if (protoObj?.constructor.prototype !== Object.prototype) {
409417
const keys = Reflect.ownKeys(protoObj);
410418
keys.forEach(k => methodsSet.add(k));
411419
}
@@ -429,12 +437,13 @@ function loadTranslation(locale, vocabularies) {
429437
// check if it is a known translation
430438
if (Translation.langs[locale]) {
431439
translation = new Translation(Translation.langs[locale]);
432-
} else if (fileExists(path.join(global.codecept_dir, locale))) {
433-
// get from a provided file instead
434-
translation = Translation.createDefault();
435-
translation.loadVocabulary(locale);
436-
} else {
440+
} else { // @ts-ignore
437441
translation = Translation.createDefault();
442+
// @ts-ignore
443+
if (fileExists(path.join(global.codecept_dir, locale))) {
444+
// get from a provided file instead
445+
translation.loadVocabulary(locale);
446+
}
438447
}
439448

440449
vocabularies.forEach(v => translation.loadVocabulary(v));

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as _codecept from './codecept.js';
2-
import workers from './workers.js';
2+
import * as workers from './workers.js';
33
import * as dataTableArgument from './data/dataTableArgument.js';
44
import * as dataTable from './data/table.js';
55
import * as within from './within.js';

0 commit comments

Comments
 (0)