@travetto/test 2.1.0 → 2.1.1

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
@@ -1,5 +1,5 @@
1
1
  import * as os from 'os';
2
- import * as fs from 'fs';
2
+ import { readFileSync } from 'fs';
3
3
 
4
4
  import { FsUtil, PathUtil, ScanFs } from '@travetto/boot';
5
5
  import { BasePlugin } from '@travetto/cli/src/plugin-base';
@@ -22,7 +22,7 @@ export class TestPlugin extends BasePlugin {
22
22
  PathUtil.resolveUnix(__dirname, '..', 'src/consumer/types/')
23
23
  )
24
24
  .filter(x => x.stats.isFile())
25
- .map(x => fs.readFileSync(x.file, 'utf8').match(/@Consumable[(]'([^']+)/)?.[1] as string);
25
+ .map(x => readFileSync(x.file, 'utf8').match(/@Consumable[(]'([^']+)/)?.[1] as string);
26
26
  }
27
27
  return this._types;
28
28
  }
package/bin/test-child.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as fs from 'fs';
1
+ import { createWriteStream } from 'fs';
2
2
 
3
3
  import { AppCache } from '@travetto/boot';
4
4
  import { EnvInit } from '@travetto/base/bin/init';
@@ -7,7 +7,7 @@ export async function customLogs() {
7
7
  const { ConsoleManager } = await import('@travetto/base');
8
8
 
9
9
  const c = new console.Console({
10
- stdout: fs.createWriteStream(AppCache.toEntryName(`test-worker.${process.pid}.log`), { flags: 'a' }),
10
+ stdout: createWriteStream(AppCache.toEntryName(`test-worker.${process.pid}.log`), { flags: 'a' }),
11
11
  inspectOptions: { depth: 4 },
12
12
  });
13
13
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@travetto/test",
3
3
  "displayName": "Testing",
4
- "version": "2.1.0",
4
+ "version": "2.1.1",
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.1.0",
33
- "@travetto/transformer": "^2.1.0",
34
- "@travetto/registry": "^2.1.0",
35
- "@travetto/watch": "^2.1.0",
36
- "@travetto/worker": "^2.1.0",
37
- "@travetto/yaml": "^2.1.0"
32
+ "@travetto/base": "^2.1.1",
33
+ "@travetto/transformer": "^2.1.1",
34
+ "@travetto/registry": "^2.1.1",
35
+ "@travetto/watch": "^2.1.1",
36
+ "@travetto/worker": "^2.1.1",
37
+ "@travetto/yaml": "^2.1.1"
38
38
  },
39
39
  "optionalPeerDependencies": {
40
- "@travetto/cli": "^2.1.0"
40
+ "@travetto/cli": "^2.1.1"
41
41
  },
42
42
  "publishConfig": {
43
43
  "access": "public"
@@ -34,7 +34,7 @@ export class AssertCheck {
34
34
  };
35
35
 
36
36
  // Invert check for negative
37
- const asrt = positive ? assert : (x: unknown, msg?: string) => assert(!x, msg);
37
+ const assertFn = positive ? assert : (x: unknown, msg?: string) => assert(!x, msg);
38
38
 
39
39
  // Check fn to call
40
40
  if (fn === 'fail') {
@@ -81,13 +81,13 @@ export class AssertCheck {
81
81
 
82
82
  // Actually run the assertion
83
83
  switch (fn) {
84
- case 'instanceof': asrt(actual instanceof (expected as Class), message); break;
85
- case 'in': asrt((actual as string) in (expected as object), message); break;
86
- case 'lessThan': asrt((actual as number) < (expected as number), message); break;
87
- case 'lessThanEqual': asrt((actual as number) <= (expected as number), message); break;
88
- case 'greaterThan': asrt((actual as number) > (expected as number), message); break;
89
- case 'greaterThanEqual': asrt((actual as number) >= (expected as number), message); break;
90
- case 'ok': asrt.apply(null, args as [unknown, string]); break; // eslint-disable-line prefer-spread
84
+ case 'instanceof': assertFn(actual instanceof (expected as Class), message); break;
85
+ case 'in': assertFn((actual as string) in (expected as object), message); break;
86
+ case 'lessThan': assertFn((actual as number) < (expected as number), message); break;
87
+ case 'lessThanEqual': assertFn((actual as number) <= (expected as number), message); break;
88
+ case 'greaterThan': assertFn((actual as number) > (expected as number), message); break;
89
+ case 'greaterThanEqual': assertFn((actual as number) >= (expected as number), message); break;
90
+ case 'ok': assertFn.apply(null, args as [unknown, string]); break; // eslint-disable-line prefer-spread
91
91
  default:
92
92
  if (fn && assert[fn as keyof typeof assert]) { // Assert call
93
93
  if (/not/i.test(fn)) {
@@ -95,7 +95,7 @@ export class AssertCheck {
95
95
  }
96
96
  assert[fn as 'ok'].apply(null, args as [boolean, string | undefined]);
97
97
  } else if (expected && !!(expected as Record<string, Function>)[fn]) { // Dotted Method call (e.g. assert.rejects)
98
- asrt((expected as typeof assert)[fn as 'ok'](actual));
98
+ assertFn((expected as typeof assert)[fn as 'ok'](actual));
99
99
  }
100
100
  }
101
101
 
@@ -1,5 +1,5 @@
1
1
  import * as path from 'path';
2
- import * as fs from 'fs';
2
+ import * as fs from 'fs/promises';
3
3
 
4
4
  import { Util } from '@travetto/base';
5
5
  import { ExecUtil, PathUtil } from '@travetto/boot';
@@ -271,7 +271,7 @@ export class TestExecutor {
271
271
  */
272
272
  static async executeIsolated(consumer: TestConsumer, file: string, ...args: string[]) {
273
273
  // Read modules for extensions
274
- const modules = [...(await fs.promises.readFile(file, 'utf8'))
274
+ const modules = [...(await fs.readFile(file, 'utf8'))
275
275
  .matchAll(/\/\/\s*@file-if\s+(@travetto\/[A-Za-z0-9\-]+)/g)]
276
276
  .map(x => x[1]);
277
277
 
@@ -1,4 +1,4 @@
1
- import * as fs from 'fs';
1
+ import { createReadStream } from 'fs';
2
2
  import * as readline from 'readline';
3
3
 
4
4
  import { ShutdownManager, Util } from '@travetto/base';
@@ -20,7 +20,7 @@ export class RunnerUtil {
20
20
  */
21
21
  static isTestFile(file: string) {
22
22
  return new Promise<boolean>((resolve) => {
23
- const input = fs.createReadStream(file);
23
+ const input = createReadStream(file);
24
24
  const reader = readline.createInterface({ input })
25
25
  .on('line', line => {
26
26
  if (line.includes('@Suite')) {