@travetto/test 2.2.0 → 2.2.3

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.
package/bin/cli-test.ts CHANGED
@@ -2,17 +2,24 @@ import * as os from 'os';
2
2
  import { readFileSync } from 'fs';
3
3
 
4
4
  import { FsUtil, PathUtil, ScanFs } from '@travetto/boot';
5
- import { BasePlugin } from '@travetto/cli/src/plugin-base';
5
+ import { CliCommand, OptionConfig } from '@travetto/cli/src/command';
6
6
  import { EnvInit } from '@travetto/base/bin/init';
7
7
 
8
8
  import type { RunState } from '../src/execute/types';
9
9
 
10
10
  const modes = ['single', 'standard'] as const;
11
11
 
12
+ type Options = {
13
+ format: OptionConfig<string>;
14
+ concurrency: OptionConfig<number>;
15
+ isolated: OptionConfig<boolean>;
16
+ mode: OptionConfig<'single' | 'standard'>;
17
+ };
18
+
12
19
  /**
13
20
  * Launch test framework and execute tests
14
21
  */
15
- export class TestPlugin extends BasePlugin {
22
+ export class TestCommand extends CliCommand<Options> {
16
23
  name = 'test';
17
24
  _types: string[];
18
25
 
@@ -28,14 +35,13 @@ export class TestPlugin extends BasePlugin {
28
35
  return this._types;
29
36
  }
30
37
 
31
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
32
- getOptions() {
38
+ getOptions(): Options {
33
39
  return {
34
40
  format: this.choiceOption({ desc: 'Output format for test results', def: 'tap', choices: this.getTypes() }),
35
41
  concurrency: this.intOption({ desc: 'Number of tests to run concurrently', lower: 1, upper: 32, def: Math.min(4, os.cpus().length - 1) }),
36
42
  isolated: this.boolOption({ desc: 'Isolated mode' }),
37
43
  mode: this.choiceOption({ desc: 'Test run mode', def: 'standard', choices: [...modes] })
38
- } as const;
44
+ };
39
45
  }
40
46
 
41
47
  envInit(): void {
package/bin/lib/run.ts CHANGED
@@ -1,5 +1,14 @@
1
1
  import type { RunState } from '../../src/execute/types';
2
2
 
3
+ declare global {
4
+ // eslint-disable-next-line @typescript-eslint/no-namespace
5
+ namespace NodeJS {
6
+ interface ProcessEnv {
7
+ TRV_TEST_DELAY?: '2s';
8
+ }
9
+ }
10
+ }
11
+
3
12
  /**
4
13
  * Run tests given the input state
5
14
  * @param opts
@@ -14,8 +23,7 @@ export async function runTests(opts: RunState): Promise<void> {
14
23
  RunnerUtil.registerCleanup('runner');
15
24
 
16
25
  if (process.env.TRV_TEST_DELAY) {
17
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
18
- await Util.wait(process.env.TRV_TEST_DELAY as '2s');
26
+ await Util.wait(process.env.TRV_TEST_DELAY);
19
27
  }
20
28
 
21
29
  try {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@travetto/test",
3
3
  "displayName": "Testing",
4
- "version": "2.2.0",
4
+ "version": "2.2.3",
5
5
  "description": "Declarative test framework",
6
6
  "keywords": [
7
7
  "unit-testing",
@@ -29,15 +29,15 @@
29
29
  "directory": "module/test"
30
30
  },
31
31
  "dependencies": {
32
- "@travetto/base": "^2.2.0",
33
- "@travetto/transformer": "^2.2.0",
34
- "@travetto/registry": "^2.2.0",
35
- "@travetto/watch": "^2.2.0",
36
- "@travetto/worker": "^2.2.0",
37
- "@travetto/yaml": "^2.2.0"
32
+ "@travetto/base": "^2.2.3",
33
+ "@travetto/transformer": "^2.2.3",
34
+ "@travetto/registry": "^2.2.3",
35
+ "@travetto/watch": "^2.2.3",
36
+ "@travetto/worker": "^2.2.3",
37
+ "@travetto/yaml": "^2.2.3"
38
38
  },
39
39
  "optionalPeerDependencies": {
40
- "@travetto/cli": "^2.2.0"
40
+ "@travetto/cli": "^2.2.3"
41
41
  },
42
42
  "publishConfig": {
43
43
  "access": "public"
@@ -21,7 +21,6 @@ export type TestResultsEnhancer = typeof COLOR_ENHANCER;
21
21
  * Dummy enhancer does nothing
22
22
  */
23
23
  export const DUMMY_ENHANCER: TestResultsEnhancer = [
24
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
25
- (Object.keys(COLOR_ENHANCER) as (keyof typeof COLOR_ENHANCER)[])
24
+ Object.keys(COLOR_ENHANCER)
26
25
  .reduce<Partial<TestResultsEnhancer>>((acc, k) => (acc[k] = (x: unknown): string => `${x}`) && acc, {})
27
26
  ].filter((x): x is TestResultsEnhancer => !!x)[0];
@@ -1,4 +1,5 @@
1
1
  import * as path from 'path';
2
+ import * as timers from 'timers/promises';
2
3
  import * as fs from 'fs/promises';
3
4
 
4
5
  import { Util } from '@travetto/base';
@@ -44,7 +45,7 @@ export class TestExecutor {
44
45
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
45
46
  await (suite.instance as Record<string, Function>)[test.methodName](); // Run
46
47
  } finally {
47
- PromiseCapture.stop().then(() => setTimeout(promCleanup.resolve, 1), promCleanup.reject);
48
+ PromiseCapture.stop().then(() => timers.setTimeout(1).then(promCleanup.resolve), promCleanup.reject);
48
49
  }
49
50
  });
50
51