Skip to content

Commit 333b215

Browse files
Copilotkobenguyent
andcommitted
Changes before error encountered
Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com>
1 parent 53c17e0 commit 333b215

File tree

25 files changed

+97
-53
lines changed

25 files changed

+97
-53
lines changed

docs/helpers/Detox.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
---
2-
permalink: /helpers/Detox
3-
sidebar: auto
4-
title: Detox
5-
---
6-
7-
# Detox
8-
9-
101
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
112

123
## Detox

lib/codecept.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,14 @@ class Codecept {
6262
await this.requireModules(this.config.require);
6363
await this.initGlobals(dir)
6464
// initializing listeners
65-
container.create(this.config, this.opts)
65+
await container.create(this.config, this.opts)
66+
67+
// Set globals that depend on container after creation
68+
if (!this.config.noGlobals) {
69+
global.inject = container.support
70+
global.share = container.share
71+
}
72+
6673
await this.runHooks()
6774
}
6875

@@ -99,8 +106,9 @@ class Codecept {
99106
const locator = await import('./locator.js');
100107
global.locate = loc => (locator.default || locator).build(loc);
101108

102-
global.inject = container.support
103-
global.share = container.share
109+
// These will be set after container.create()
110+
global.inject = null
111+
global.share = null
104112

105113
const secret = await import('./secret.js');
106114
global.secret = secret.secret;

lib/command/check.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default async function (options) {
4545
let codecept
4646
try {
4747
codecept = new Codecept(config, options)
48-
codecept.init(testRoot)
48+
await codecept.init(testRoot)
4949
await container.started()
5050
checks.container = true
5151
} catch (err) {

lib/command/definitions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export default function (genPath, options) {
106106
const targetFolderPath = (options.output && getTestRoot(options.output)) || testsPath
107107

108108
const codecept = new Codecept(config, {})
109-
codecept.init(testsPath)
109+
await codecept.init(testsPath)
110110

111111
const helpers = container.helpers()
112112
const translations = container.translation()

lib/command/dryRun.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import output from '../output.js'
55
import event from '../event.js'
66
import store from '../store.js'
77
import Container from '../container.js'
8+
import figures from 'figures'
9+
import colors from 'chalk'
810

911
export default async function (test, options) {
1012
if (options.grep) process.env.grep = options.grep
@@ -27,7 +29,7 @@ export default async function (test, options) {
2729

2830
try {
2931
codecept = new Codecept(config, options)
30-
codecept.init(testRoot)
32+
await codecept.init(testRoot)
3133

3234
if (options.bootstrap) await codecept.bootstrap()
3335

@@ -47,9 +49,6 @@ export default async function (test, options) {
4749
}
4850

4951
function printTests(files) {
50-
import figures from 'figures'
51-
import colors from 'chalk'
52-
5352
output.print(output.styles.debug(`Tests from ${global.codecept_dir}:`))
5453
output.print()
5554

lib/command/generate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { fileExists, ucfirst, lcfirst, beautify } from '../utils.js'
77
import output from '../output.js'
88
import generateDefinitions from './definitions.js'
99
import { getConfigSync, getTestRoot, safeFileWrite, readConfig } from './utils.js'
10+
import container from '../container.js'
1011

1112
let extension = 'js'
1213

@@ -55,7 +56,6 @@ export const test = function (genPath) {
5556
if (!fileExists(dir)) mkdirp.sync(dir)
5657
let testContent = testTemplate.replace('{{feature}}', result.feature)
5758

58-
import container from '../container.js'
5959
container.create(config, {})
6060
// translate scenario test
6161
if (container.translation().loaded) {

lib/command/gherkin/snippets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default function (genPath, options) {
2323
if (!config) return
2424

2525
const codecept = new Codecept(config, {})
26-
codecept.init(testsPath)
26+
await codecept.init(testsPath)
2727

2828
if (!config.gherkin) {
2929
output.error('Gherkin is not enabled in config. Run `codecept gherkin:init` to enable it')

lib/command/gherkin/steps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default function (genPath, options) {
1010
if (!config) return
1111

1212
const codecept = new Codecept(config, {})
13-
codecept.init(testsPath)
13+
await codecept.init(testsPath)
1414

1515
output.print('Gherkin Step Definitions:')
1616
output.print()

lib/command/info.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default async function (path) {
4444
const testsPath = getTestRoot(path)
4545
const config = await getConfig(testsPath)
4646
const codecept = new Codecept(config, {})
47-
codecept.init(testsPath)
47+
await codecept.init(testsPath)
4848

4949
output.print('\n Environment information: \n')
5050
const info = {}

lib/command/init.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ const defaultConfig = {
2121
}
2222

2323
const helpers = ['Playwright', 'WebDriver', 'Puppeteer', 'REST', 'GraphQL', 'Appium', 'TestCafe']
24-
const translations = Object.keys((await import('../../translations.js')).default)
24+
const translationsModule = await import('../translations/index.js')
25+
const translations = Object.keys(translationsModule.default)
2526

2627
const noTranslation = 'English (no localization)'
2728
translations.unshift(noTranslation)
@@ -399,7 +400,7 @@ function _actorTranslation(stepFile, translationSelected) {
399400
}
400401

401402
if (translationSelected === translationAvailable) {
402-
import nameOfActor from '../../translations.js'
403+
const nameOfActor = translationsModule.default[translationAvailable].I
403404

404405
actor = {
405406
[nameOfActor]: stepFile,

0 commit comments

Comments
 (0)