@brillout/test-e2e 0.4.17 → 0.5.0

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.
@@ -2,6 +2,7 @@ export { getConfig };
2
2
  export { loadConfig };
3
3
  declare type Config = {
4
4
  tolerateError?: Function;
5
+ tolerateSkip?: boolean;
5
6
  };
6
7
  declare function getConfig(): Config;
7
8
  declare function loadConfig(): Promise<void>;
package/dist/getConfig.js CHANGED
@@ -8,7 +8,6 @@ const path_1 = __importDefault(require("path"));
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const utils_1 = require("./utils");
10
10
  const configFileName = 'test-e2e.config.mjs';
11
- const errPrefix = `Config file \`${configFileName}\` `;
12
11
  let config = null;
13
12
  function getConfig() {
14
13
  (0, utils_1.assert)(config);
@@ -17,18 +16,27 @@ function getConfig() {
17
16
  exports.getConfig = getConfig;
18
17
  async function loadConfig() {
19
18
  const configFilePath = find();
20
- (0, utils_1.assertUsage)(configFilePath, errPrefix + 'not found');
19
+ (0, utils_1.assertUsage)(configFilePath, `${configFileName} not found`);
21
20
  const configFileExports = (await import((0, utils_1.fsWindowsBugWorkaround)(configFilePath)));
22
- (0, utils_1.assertUsage)('default' in configFileExports, errPrefix + 'should have a default export');
21
+ (0, utils_1.assertUsage)('default' in configFileExports, `${configFileName} should have a default export`);
23
22
  assertConfig(configFileExports.default);
24
23
  config = configFileExports.default;
25
24
  }
26
25
  exports.loadConfig = loadConfig;
27
26
  function assertConfig(config) {
28
- (0, utils_1.assertUsage)((0, utils_1.isObject)(config), errPrefix + 'default export should be an object');
29
- if ('tolerateError' in config) {
30
- (0, utils_1.assertUsage)((0, utils_1.isCallable)(config.tolerateError), errPrefix + '`tolerateError` should be a function');
31
- }
27
+ (0, utils_1.assertUsage)((0, utils_1.isObject)(config), `${configFileName} default export should be an object`);
28
+ Object.entries(config).forEach(([key, val]) => {
29
+ const wrongType = `${configFileName} export default { ${key} } should be a`;
30
+ if (key === 'tolerateError') {
31
+ (0, utils_1.assertUsage)((0, utils_1.isCallable)(val), `${wrongType} function`);
32
+ }
33
+ else if (key === 'tolerateSkip') {
34
+ (0, utils_1.assertUsage)(typeof val === 'boolean', `${wrongType} boolean`);
35
+ }
36
+ else {
37
+ (0, utils_1.assertUsage)(false, `${configFileName} unknown config ${key}`);
38
+ }
39
+ });
32
40
  }
33
41
  function find() {
34
42
  let dir = process.cwd();
@@ -1,4 +1,6 @@
1
+ export { isParallelCI };
1
2
  export { abortIfParallelCI };
2
3
  export { getTestFilesForCurrentJob };
3
4
  declare function abortIfParallelCI(): void;
5
+ declare function isParallelCI(): boolean;
4
6
  declare function getTestFilesForCurrentJob(): null | string[];
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getTestFilesForCurrentJob = exports.abortIfParallelCI = void 0;
6
+ exports.getTestFilesForCurrentJob = exports.abortIfParallelCI = exports.isParallelCI = void 0;
7
7
  const utils_1 = require("./utils");
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const path_1 = __importDefault(require("path"));
@@ -17,6 +17,7 @@ exports.abortIfParallelCI = abortIfParallelCI;
17
17
  function isParallelCI() {
18
18
  return getTestFilesForCurrentJob() !== null;
19
19
  }
20
+ exports.isParallelCI = isParallelCI;
20
21
  function getTestFilesForCurrentJob() {
21
22
  if (!('TEST_FILES' in process.env))
22
23
  return null;
package/dist/runAll.js CHANGED
@@ -62,9 +62,8 @@ async function runServerAndTests(browser, isSecondAttempt) {
62
62
  const testInfo = (0, getCurrentTest_1.getCurrentTest)();
63
63
  // Set when user calls `skip()`
64
64
  if (testInfo.skipped) {
65
+ assertSkipUsage(testInfo);
65
66
  (0, logTestStatus_1.logWarn)(testInfo.skipped);
66
- (0, utils_1.assertUsage)(!testInfo.runInfo, 'You cannot call `run()` after calling `skip()`');
67
- (0, utils_1.assertUsage)(testInfo.tests === undefined, 'You cannot call `test()` after calling `skip()`');
68
67
  return true;
69
68
  }
70
69
  // Set when user calls `run()`
@@ -184,3 +183,22 @@ function runTest(testFn, testFunctionTimeout) {
184
183
  })();
185
184
  return promise;
186
185
  }
186
+ function assertSkipUsage(testInfo) {
187
+ {
188
+ const err = 'You cannot call run() after calling skip()';
189
+ (0, utils_1.assertUsage)(testInfo.runInfo === undefined, err);
190
+ }
191
+ {
192
+ const err = 'You cannot call test() after calling skip()';
193
+ (0, utils_1.assertUsage)(testInfo.tests === undefined, err);
194
+ }
195
+ const config = (0, getConfig_1.getConfig)();
196
+ {
197
+ const err = 'Using skip() while config tolerateSkip is set to false';
198
+ (0, utils_1.assertUsage)(config.tolerateSkip !== false, err);
199
+ }
200
+ {
201
+ const err = 'Using skip() while config tolerateSkip is set to undefined and tests are running in a parallel CI';
202
+ (0, utils_1.assertUsage)(!(config.tolerateSkip === undefined && (0, parallel_ci_1.isParallelCI)()), err);
203
+ }
204
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/test-e2e",
3
- "version": "0.4.17",
3
+ "version": "0.5.0",
4
4
  "bin": "./bin.js",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {