Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@travetto/test

Package Overview
Dependencies
Maintainers
0
Versions
352
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@travetto/test - npm Package Compare versions

Comparing version 5.0.0-rc.6 to 5.0.0-rc.7

14

package.json
{
"name": "@travetto/test",
"version": "5.0.0-rc.6",
"version": "5.0.0-rc.7",
"description": "Declarative test framework",

@@ -30,11 +30,11 @@ "keywords": [

"dependencies": {
"@travetto/runtime": "^5.0.0-rc.6",
"@travetto/registry": "^5.0.0-rc.6",
"@travetto/terminal": "^5.0.0-rc.6",
"@travetto/worker": "^5.0.0-rc.6",
"@travetto/runtime": "^5.0.0-rc.7",
"@travetto/registry": "^5.0.0-rc.7",
"@travetto/terminal": "^5.0.0-rc.7",
"@travetto/worker": "^5.0.0-rc.7",
"yaml": "^2.4.5"
},
"peerDependencies": {
"@travetto/cli": "^5.0.0-rc.6",
"@travetto/transformer": "^5.0.0-rc.4"
"@travetto/cli": "^5.0.0-rc.7",
"@travetto/transformer": "^5.0.0-rc.5"
},

@@ -41,0 +41,0 @@ "peerDependenciesMeta": {

@@ -21,3 +21,3 @@ <!-- This file was generated by @travetto/doc and should not be modified directly -->

**Note**: All tests should be under the `test/.*` folders. The pattern for tests is defined as a regex and not standard globbing.
**Note**: All tests should be under the `**/*` folders. The pattern for tests is defined as as a standard glob using [Node](https://nodejs.org)'s built in globbing support.

@@ -86,3 +86,3 @@ ## Definition

const Ⲑ_function_1 = tslib_1.__importStar(require("@travetto/runtime/src/function.js"));
var ᚕm = ["@travetto/test", "doc/assert-example"];
var ᚕm = ["@travetto/test", "doc/assert-example.ts"];
const node_assert_1 = tslib_1.__importDefault(require("node:assert"));

@@ -89,0 +89,0 @@ const test_1 = require("@travetto/test");

@@ -261,5 +261,4 @@ import { AssertionError } from 'node:assert';

static async execute(consumer: TestConsumer, imp: string, ...args: string[]): Promise<void> {
try {
await import(imp);
await Runtime.importFrom(imp);
} catch (err) {

@@ -266,0 +265,0 @@ if (!(err instanceof Error)) {

@@ -32,3 +32,3 @@ import path from 'node:path';

console.debug('Running', { imports, patterns: this.#state.args });
console.debug('Running', { patterns: this.#state.args });

@@ -35,0 +35,0 @@ const testCount = await RunnerUtil.getTestCount(this.#state.args);

@@ -39,24 +39,26 @@ import { spawn } from 'node:child_process';

*/
static async getTestImports(globs?: string[]): Promise<string[]> {
const files = new Set<string>();
static async* getTestImports(globs?: string[]): AsyncIterable<string> {
const all = RuntimeIndex.find({
module: m => m.roles.includes('test') || m.roles.includes('std'),
folder: f => f === 'test',
file: f => f.role === 'test'
});
// Collect globs
if (globs) {
if (globs?.length) {
const allFiles = new Map(all.map(x => [x.sourceFile, x]));
for await (const item of fs.glob(globs)) {
files.add(Runtime.workspaceRelative(item));
const src = Runtime.workspaceRelative(item);
const match = allFiles.get(src);
if (match && await this.isTestFile(match.sourceFile)) {
yield match.import;
}
}
} else {
for await (const match of all) {
if (await this.isTestFile(match.sourceFile)) {
yield match.import;
}
}
}
const found = RuntimeIndex.find({
module: m => m.roles.includes('test') || m.roles.includes('std'),
folder: f => f === 'test',
file: f => f.role === 'test'
})
.filter(f => files.size === 0 || files.has(f.sourceFile));
const validImports = found
.map(f => this.isTestFile(f.sourceFile).then(valid => ({ import: f.import, valid })));
return (await Promise.all(validImports))
.filter(x => x.valid)
.map(x => x.import);
}

@@ -63,0 +65,0 @@

@@ -85,4 +85,4 @@ import { RootRegistry, MethodSource } from '@travetto/registry';

if (runAllOnStart) {
for (const imp of await RunnerUtil.getTestImports()) {
await import(imp);
for await (const imp of await RunnerUtil.getTestImports()) {
await Runtime.importFrom(imp);
itr.add(imp);

@@ -89,0 +89,0 @@ }

@@ -15,9 +15,9 @@ import { fork } from 'node:child_process';

export async function buildStandardTestManager(consumer: TestConsumer, imp: string | RunRequest): Promise<void> {
process.send?.({ type: 'log', message: `Worker Executing ${imp}` });
let event: RunEvent;
process.send?.({ type: 'log', message: `Worker Input ${JSON.stringify(imp)}` });
let event: RunEvent;
if (typeof imp === 'string') {
event = { import: imp };
} else if ('file' in imp) {
event = { import: RuntimeIndex.getFromSource(imp.file)?.sourceFile!, class: imp.class, method: imp.method };
event = { import: RuntimeIndex.getFromSource(imp.file)?.import!, class: imp.class, method: imp.method };
} else {

@@ -27,2 +27,4 @@ event = imp;

process.send?.({ type: 'log', message: `Worker Executing ${event.import}` });
const { module } = RuntimeIndex.getFromImport(event.import!)!;

@@ -69,3 +71,3 @@ const suiteMod = RuntimeIndex.getModule(module);

process.send?.({ type: 'log', message: `Worker Finished ${imp}` });
process.send?.({ type: 'log', message: `Worker Finished ${event.import}` });

@@ -72,0 +74,0 @@ // If we received an error, throw it

import { CliCommand } from '@travetto/cli';
import { Env, describeFunction } from '@travetto/runtime';
import { Env, Runtime, describeFunction } from '@travetto/runtime';

@@ -16,8 +16,6 @@ import { SuiteRegistry } from '../src/registry/suite';

async main(patterns: string[]) {
const imports = await RunnerUtil.getTestImports(patterns);
// Load all tests
for (const imp of imports) {
for await (const imp of await RunnerUtil.getTestImports(patterns)) {
try {
await import(imp);
await Runtime.importFrom(imp);
} catch (err) {

@@ -24,0 +22,0 @@ console.error('Failed to import', imp, err);

@@ -42,3 +42,3 @@ import { EventEmitter } from 'node:events';

async validate(first: string = 'test/.*', rest: string[]): Promise<CliValidationError | undefined> {
async validate(first: string = '**/*', rest: string[]): Promise<CliValidationError | undefined> {

@@ -52,3 +52,3 @@ const mode = await this.resolvedMode(first, rest);

async main(first: string = 'test/.*', regexes: string[] = []): Promise<void> {
async main(first: string = '**/*', regexes: string[] = []): Promise<void> {
const { runTests } = await import('./bin/run');

@@ -55,0 +55,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc