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

@callstack/reassure-cli

Package Overview
Dependencies
Maintainers
11
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@callstack/reassure-cli - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

51

lib/commonjs/commands/measure.js

@@ -20,2 +20,4 @@ "use strict";

function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
// Jest default testMatch: [ "**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)" ]
const DEFAULT_TEST_MATCH = ['**/__perf__/**/*.[jt]s?(x)', '**/*.(perf|perf-test).[jt]s?(x)'];
async function run(options) {

@@ -42,2 +44,4 @@ (0, _logger.configureLoggerOptions)(options);

(0, _nodeFs.writeFileSync)(outputFile, JSON.stringify(header) + '\n');
const nodeMajorVersion = (0, _node.getNodeMajorVersion)();
logger.verbose(`Node.js version: ${nodeMajorVersion} (${process.versions.node})`);
const testRunnerPath = process.env.TEST_RUNNER_PATH ?? (0, _node.getJestBinPath)();

@@ -49,18 +53,5 @@ if (!testRunnerPath) {

}
// NOTE: Consider updating the default testMatch to better reflect
// default patterns used in Jest and allow users to also place their
// performance tests into specific /__perf__/ directory without the need
// of adding the *.perf-test. prefix
// ---
// [ **/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)" ]
// ---
// GH: https://github.com/callstack/reassure/issues/363
const defaultTestMatch = '**/*.perf-test.[jt]s?(x)';
const testMatch = options.testMatch || defaultTestMatch;
const defaultArgs = `--runInBand --testMatch "<rootDir>/${testMatch}"`;
const testRunnerArgs = process.env.TEST_RUNNER_ARGS ?? defaultArgs;
const nodeMajorVersion = (0, _node.getNodeMajorVersion)();
logger.verbose(`Node.js version: ${nodeMajorVersion} (${process.versions.node})`);
const nodeArgs = [...(0, _node.getNodeFlags)(nodeMajorVersion), testRunnerPath, testRunnerArgs];
const baseTestRunnerArgs = process.env.TEST_RUNNER_ARGS ?? buildDefaultTestRunnerArgs(options);
const passthroughTestRunnerArgs = options._ ?? [];
const nodeArgs = [...(0, _node.getNodeFlags)(nodeMajorVersion), testRunnerPath, ...baseTestRunnerArgs, ...passthroughTestRunnerArgs];
logger.verbose('Running tests using command:');

@@ -124,4 +115,8 @@ logger.verbose(`$ node \\\n ${nodeArgs.join(' \\\n ')}\n`);

type: 'string',
default: undefined,
describe: 'Run performance tests for a specific test file'
array: true,
describe: 'The glob patterns Reassure uses to detect perf test files'
}).option('testRegex', {
type: 'string',
array: true,
describe: 'The regexp patterns Reassure uses to detect perf test files'
});

@@ -131,2 +126,22 @@ },

};
function buildDefaultTestRunnerArgs(options) {
if (options.testMatch && options.testRegex) {
logger.error('Configuration options "testMatch" and "testRegex" cannot be used together.');
process.exit(1);
}
const commonArgs = ['--runInBand'];
if (options.testMatch) {
return [...commonArgs, `--testMatch=${toShellArray(options.testMatch)}`];
}
if (options.testRegex) {
return [...commonArgs, `--testRegex=${toShellArray(options.testRegex)}`];
}
return [...commonArgs, `--testMatch=${toShellArray(DEFAULT_TEST_MATCH)}`];
}
function toShellArray(texts) {
return texts.map(shellEscape).map(text => `"${text}"`).join(' ');
}
function shellEscape(text) {
return text.replace(/(["'$`\\])/g, '\\$1');
}
//# sourceMappingURL=measure.js.map

@@ -11,2 +11,5 @@ import { existsSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';

import { getJestBinPath, getNodeFlags, getNodeMajorVersion } from '../utils/node';
// Jest default testMatch: [ "**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)" ]
const DEFAULT_TEST_MATCH = ['**/__perf__/**/*.[jt]s?(x)', '**/*.(perf|perf-test).[jt]s?(x)'];
export async function run(options) {

@@ -33,2 +36,4 @@ configureLoggerOptions(options);

writeFileSync(outputFile, JSON.stringify(header) + '\n');
const nodeMajorVersion = getNodeMajorVersion();
logger.verbose(`Node.js version: ${nodeMajorVersion} (${process.versions.node})`);
const testRunnerPath = process.env.TEST_RUNNER_PATH ?? getJestBinPath();

@@ -40,18 +45,5 @@ if (!testRunnerPath) {

}
// NOTE: Consider updating the default testMatch to better reflect
// default patterns used in Jest and allow users to also place their
// performance tests into specific /__perf__/ directory without the need
// of adding the *.perf-test. prefix
// ---
// [ **/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)" ]
// ---
// GH: https://github.com/callstack/reassure/issues/363
const defaultTestMatch = '**/*.perf-test.[jt]s?(x)';
const testMatch = options.testMatch || defaultTestMatch;
const defaultArgs = `--runInBand --testMatch "<rootDir>/${testMatch}"`;
const testRunnerArgs = process.env.TEST_RUNNER_ARGS ?? defaultArgs;
const nodeMajorVersion = getNodeMajorVersion();
logger.verbose(`Node.js version: ${nodeMajorVersion} (${process.versions.node})`);
const nodeArgs = [...getNodeFlags(nodeMajorVersion), testRunnerPath, testRunnerArgs];
const baseTestRunnerArgs = process.env.TEST_RUNNER_ARGS ?? buildDefaultTestRunnerArgs(options);
const passthroughTestRunnerArgs = options._ ?? [];
const nodeArgs = [...getNodeFlags(nodeMajorVersion), testRunnerPath, ...baseTestRunnerArgs, ...passthroughTestRunnerArgs];
logger.verbose('Running tests using command:');

@@ -115,4 +107,8 @@ logger.verbose(`$ node \\\n ${nodeArgs.join(' \\\n ')}\n`);

type: 'string',
default: undefined,
describe: 'Run performance tests for a specific test file'
array: true,
describe: 'The glob patterns Reassure uses to detect perf test files'
}).option('testRegex', {
type: 'string',
array: true,
describe: 'The regexp patterns Reassure uses to detect perf test files'
});

@@ -122,2 +118,22 @@ },

};
function buildDefaultTestRunnerArgs(options) {
if (options.testMatch && options.testRegex) {
logger.error('Configuration options "testMatch" and "testRegex" cannot be used together.');
process.exit(1);
}
const commonArgs = ['--runInBand'];
if (options.testMatch) {
return [...commonArgs, `--testMatch=${toShellArray(options.testMatch)}`];
}
if (options.testRegex) {
return [...commonArgs, `--testRegex=${toShellArray(options.testRegex)}`];
}
return [...commonArgs, `--testMatch=${toShellArray(DEFAULT_TEST_MATCH)}`];
}
function toShellArray(texts) {
return texts.map(shellEscape).map(text => `"${text}"`).join(' ');
}
function shellEscape(text) {
return text.replace(/(["'$`\\])/g, '\\$1');
}
//# sourceMappingURL=measure.js.map

@@ -8,4 +8,6 @@ import type { CommandModule } from 'yargs';

commitHash?: string;
testMatch?: string;
enableWasm?: boolean;
testMatch?: string[];
testRegex?: string[];
/** Rest argument used for flags after `--` separator, will be passed to test runner. */
_?: string[];
}

@@ -12,0 +14,0 @@ export declare function run(options: MeasureOptions): Promise<void>;

{
"name": "@callstack/reassure-cli",
"version": "1.1.0",
"version": "1.2.0",
"description": "Performance testing companion for React and React Native",

@@ -49,4 +49,4 @@ "main": "lib/commonjs/index.js",

"dependencies": {
"@callstack/reassure-compare": "1.1.0",
"@callstack/reassure-logger": "1.1.0",
"@callstack/reassure-compare": "1.2.0",
"@callstack/reassure-logger": "1.2.0",
"chalk": "4.1.2",

@@ -53,0 +53,0 @@ "simple-git": "^3.25.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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