codeceptjs 3.3.5-beta.4 → 3.3.5-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,9 +30,10 @@ const packages = [];
30
30
  let isTypeScript = false;
31
31
  let extension = 'js';
32
32
 
33
- const configHeader = `const { setHeadlessWhen, setCommonPlugins } = require('@codeceptjs/configure');
34
-
33
+ const requireCodeceptConfigure = "const { setHeadlessWhen, setCommonPlugins } = require('@codeceptjs/configure');";
34
+ const importCodeceptConfigure = "import { setHeadlessWhen, setCommonPlugins } from '@codeceptjs/configure';"
35
35
 
36
+ const configHeader = `
36
37
  // turn on headless mode when running with HEADLESS=true environment variable
37
38
  // export HEADLESS=true && npx codeceptjs run
38
39
  setHeadlessWhen(process.env.HEADLESS);
@@ -174,18 +175,21 @@ module.exports = function (initPath) {
174
175
  print(`Steps file created at ${stepFile}`);
175
176
  }
176
177
 
177
- let configSource = beautify(`/** @type {CodeceptJS.MainConfig} */\nexports.config = ${inspect(config, false, 4, false)}`);
178
-
179
- if (require.resolve('@codeceptjs/configure') && isLocal && !initPath) {
180
- // prepend @codeceptjs/configure only when this module can be required in config
181
- configSource = configHeader + configSource;
182
- }
178
+ let configSource;
179
+ const hasConfigure = isLocal && !initPath;
183
180
 
184
181
  if (isTypeScript) {
185
182
  configSource = beautify(`export const config : CodeceptJS.MainConfig = ${inspect(config, false, 4, false)}`);
183
+
184
+ if (hasConfigure) configSource = requireCodeceptConfigure + configHeader + configSource;
185
+
186
186
  fs.writeFileSync(typeScriptconfigFile, configSource, 'utf-8');
187
187
  print(`Config created at ${typeScriptconfigFile}`);
188
188
  } else {
189
+ configSource = beautify(`/** @type {CodeceptJS.MainConfig} */\nexports.config = ${inspect(config, false, 4, false)}`);
190
+
191
+ if (hasConfigure) configSource = importCodeceptConfigure + configHeader + configSource;
192
+
189
193
  fs.writeFileSync(configFile, configSource, 'utf-8');
190
194
  print(`Config created at ${configFile}`);
191
195
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeceptjs",
3
- "version": "3.3.5-beta.4",
3
+ "version": "3.3.5-beta.5",
4
4
  "description": "Supercharged End 2 End Testing Framework for NodeJS",
5
5
  "keywords": [
6
6
  "acceptance",