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

folio

Package Overview
Dependencies
Maintainers
6
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

folio - npm Package Compare versions

Comparing version 0.4.0-alpha23 to 0.4.0-alpha24

43

out/cli.js

@@ -36,3 +36,7 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const inspector_1 = __importDefault(require("inspector"));
const commander = __importStar(require("commander"));

@@ -46,2 +50,4 @@ const fs = __importStar(require("fs"));

const builtinReporters = ['list', 'line', 'dot', 'json', 'junit', 'null'];
const tsConfig = 'folio.config.ts';
const jsConfig = 'folio.config.js';
const defaultConfig = {

@@ -56,13 +62,12 @@ preserveOutput: process.env.CI ? 'failures-only' : 'always',

program.name('folio');
program.usage('[filter...] [options]');
program.description('Use [filter...] arguments to filter test files. Each argument is treated as a regular expression.');
program.arguments('[test-filter...]');
program.helpOption(false);
program.option('-h, --help', `Display help`);
program.option('-c, --config <file>', `Configuration file (default: "folio.config.ts" or "folio.config.js")`);
program.option('--forbid-only', `Fail if exclusive test(s) encountered (default: ${defaultConfig.forbidOnly})`);
program.option('-g, --grep <grep>', `Only run tests matching this regular expression (default: "${defaultConfig.grep}")`);
program.option('--global-timeout <timeout>', `Maximum time this test suite can run in milliseconds (default: 0 for unlimited)`);
program.option('-j, --workers <workers>', `Number of concurrent workers, use 1 to run in single worker (default: number of CPU cores / 2)`);
program.option('-c, --config <file>', `Configuration file, or a test directory with optional "${tsConfig}"/"${jsConfig}"`);
program.option('--forbid-only', `Fail if test.only is called (default: false)`);
program.option('-g, --grep <grep>', `Only run tests matching this regular expression (default: ".*")`);
program.option('--global-timeout <timeout>', `Maximum time this test suite can run in milliseconds (default: unlimited)`);
program.option('-j, --workers <workers>', `Number of concurrent workers, use 1 to run in a single worker (default: number of CPU cores / 2)`);
program.option('--list', `Collect all the tests and report them, but do not run`);
program.option('--max-failures <N>', `Stop after the first N failures (default: do not stop until all tests are run)`);
program.option('--max-failures <N>', `Stop after the first N failures`);
program.option('--output <dir>', `Folder for output artifacts (default: "test-results")`);

@@ -72,8 +77,8 @@ program.option('--quiet', `Suppress stdio`);

program.option('--reporter <reporter>', `Reporter to use, comma-separated, can be ${builtinReporters.map(name => `"${name}"`).join(', ')} (default: "${defaultReporter}")`);
program.option('--retries <retries>', `Maximum retry count for flaky tests (default: 0 for no retries)`);
program.option('--retries <retries>', `Maximum retry count for flaky tests, zero for no retries (default: no retries)`);
program.option('--shard <shard>', `Shard tests and execute only the selected shard, specify in the form "current/all", 1-based, for example "3/5"`);
program.option('--project <project-name>', `Only run tests from the specified project (default: run all projects)`);
program.option('--timeout <timeout>', `Specify test timeout threshold in milliseconds (default: ${defaultTimeout})`);
program.option('--timeout <timeout>', `Specify test timeout threshold in milliseconds, zero for unlimited (default: ${defaultTimeout})`);
program.option('-u, --update-snapshots', `Update snapshots with actual results (default: only create missing snapshots)`);
program.option('-x', `Stop after the first failure (default: do not stop until all tests are run)`);
program.option('-x', `Stop after the first failure`);
program.version('Folio version ' + require('../package.json').version, '-v, --version', 'Output the version number');

@@ -94,2 +99,9 @@ program.parse(process.argv);

console.log(program.helpInformation());
console.log('');
console.log('Arguments [test-filter...]:');
console.log(' Pass arguments to filter test files. Each argument is treated as a regular expression.');
console.log('');
console.log('Examples:');
console.log(' $ folio my.spec.ts');
console.log(' $ folio -c tests/');
process.exit(0);

@@ -107,4 +119,2 @@ }

}
const tsConfig = 'folio.config.ts';
const jsConfig = 'folio.config.js';
if (opts.config) {

@@ -122,3 +132,3 @@ const configFile = path.resolve(process.cwd(), opts.config);

// When passed a file, it must be a config file.
loadConfig(path.resolve(process.cwd(), opts.config));
loadConfig(configFile);
}

@@ -138,5 +148,6 @@ }

const shardPair = options.shard ? options.shard.split('/').map((t) => parseInt(t, 10)) : undefined;
const isDebuggerAttached = !!inspector_1.default.url();
return {
forbidOnly: options.forbidOnly ? true : undefined,
globalTimeout: options.globalTimeout ? parseInt(options.globalTimeout, 10) : undefined,
globalTimeout: isDebuggerAttached ? 0 : (options.globalTimeout ? parseInt(options.globalTimeout, 10) : undefined),
grep: options.grep ? util_1.forceRegExp(options.grep) : undefined,

@@ -152,3 +163,3 @@ maxFailures: options.x ? 1 : (options.maxFailures ? parseInt(options.maxFailures, 10) : undefined),

shard: shardPair ? { current: shardPair[0] - 1, total: shardPair[1] } : undefined,
timeout: options.timeout ? parseInt(options.timeout, 10) : undefined,
timeout: isDebuggerAttached ? 0 : (options.timeout ? parseInt(options.timeout, 10) : undefined),
updateSnapshots: options.updateSnapshots ? 'all' : undefined,

@@ -155,0 +166,0 @@ workers: options.workers ? parseInt(options.workers, 10) : undefined,

@@ -287,3 +287,3 @@ "use strict";

DEBUG_COLORS: process.stdout.isTTY ? '1' : '0',
FOLIO_WORKER_INDEX: String(this.index),
TEST_WORKER_INDEX: String(this.index),
...process.env

@@ -290,0 +290,0 @@ },

@@ -28,4 +28,5 @@ "use strict";

const pixelmatch_1 = __importDefault(require("pixelmatch"));
const pngjs_1 = require("pngjs");
const diff_match_patch_1 = require("../third_party/diff_match_patch");
// Note: we require the pngjs version of pixelmatch to avoid version mismatches.
const { PNG } = require(require.resolve('pngjs', { paths: [require.resolve('pixelmatch')] }));
const extensionToMimeType = {

@@ -54,4 +55,4 @@ 'dat': 'application/octet-string',

return { errorMessage: 'Actual result should be Buffer.' };
const actual = mimeType === 'image/png' ? pngjs_1.PNG.sync.read(actualBuffer) : jpeg_js_1.default.decode(actualBuffer);
const expected = mimeType === 'image/png' ? pngjs_1.PNG.sync.read(expectedBuffer) : jpeg_js_1.default.decode(expectedBuffer);
const actual = mimeType === 'image/png' ? PNG.sync.read(actualBuffer) : jpeg_js_1.default.decode(actualBuffer);
const expected = mimeType === 'image/png' ? PNG.sync.read(expectedBuffer) : jpeg_js_1.default.decode(expectedBuffer);
if (expected.width !== actual.width || expected.height !== actual.height) {

@@ -62,5 +63,5 @@ return {

}
const diff = new pngjs_1.PNG({ width: expected.width, height: expected.height });
const diff = new PNG({ width: expected.width, height: expected.height });
const count = pixelmatch_1.default(expected.data, actual.data, diff.data, expected.width, expected.height, { threshold: 0.2, ...options });
return count > 0 ? { diff: pngjs_1.PNG.sync.write(diff) } : null;
return count > 0 ? { diff: PNG.sync.write(diff) } : null;
}

@@ -67,0 +68,0 @@ function compareText(actual, expectedBuffer) {

@@ -34,3 +34,3 @@ /**

loadTestFile(file: string): Suite;
loadGlobalHook(file: string): () => any;
loadGlobalHook(file: string, name: string): (config: FullConfig) => any;
fullConfig(): FullConfig;

@@ -37,0 +37,0 @@ projects(): ProjectImpl[];

@@ -134,8 +134,10 @@ "use strict";

}
loadGlobalHook(file) {
loadGlobalHook(file, name) {
const revertBabelRequire = transform_1.installTransform();
try {
const hook = require(file);
let hook = require(file);
if (hook && typeof hook === 'object' && ('default' in hook))
hook = hook['default'];
if (typeof hook !== 'function')
throw util_1.errorWithCallLocation(`globalSetup and globalTeardown files must export a single function.`);
throw util_1.errorWithCallLocation(`${name} file must export a single function.`);
return hook;

@@ -142,0 +144,0 @@ }

@@ -163,4 +163,5 @@ "use strict";

}
let globalSetupResult;
if (config.globalSetup)
await this._loader.loadGlobalHook(config.globalSetup)();
globalSetupResult = await this._loader.loadGlobalHook(config.globalSetup, 'globalSetup')(this._loader.fullConfig());
try {

@@ -231,4 +232,6 @@ for (const file of allTestFiles)

finally {
if (globalSetupResult && typeof globalSetupResult === 'function')
await globalSetupResult(this._loader.fullConfig());
if (config.globalTeardown)
await this._loader.loadGlobalHook(config.globalTeardown)();
await this._loader.loadGlobalHook(config.globalTeardown, 'globalTeardown')(this._loader.fullConfig());
}

@@ -235,0 +238,0 @@ }

@@ -214,3 +214,3 @@ /**

/**
* Unique worker index. Also available as `process.env.FOLIO_WORKER_INDEX`.
* Unique worker index. Also available as `process.env.TEST_WORKER_INDEX`.
*/

@@ -217,0 +217,0 @@ workerIndex: number;

{
"name": "folio",
"version": "0.4.0-alpha23",
"version": "0.4.0-alpha24",
"bin": {

@@ -46,5 +46,4 @@ "folio": "./cli.js"

"pixelmatch": "^5.2.1",
"pngjs": "^5.0.0",
"rimraf": "^3.0.2",
"source-map-support": "^0.5.19",
"source-map-support": "^0.4.18",
"stack-utils": "^2.0.2"

@@ -51,0 +50,0 @@ },

@@ -818,19 +818,22 @@ # Folio ![npm](https://img.shields.io/npm/v/folio)

Global setup function takes the [configuration object](#configuration-object) as a parameter. If it returns a function, this function is treated as a global teardown and will be run at the end.
```ts
// global-setup.ts
import * as http from 'http';
import app from './my-app';
module.exports = async () => {
async function globalSetup() {
const server = http.createServer(app);
await new Promise(done => server.listen(done));
process.env.SERVER_PORT = String(server.address().port); // Expose port to the tests.
global.__server = server; // Save the server for the teardown.
};
```
```ts
// global-teardown.ts
module.exports = async () => {
await new Promise(done => global.__server.close(done));
};
// Expose port to the tests.
process.env.SERVER_PORT = String(server.address().port);
// Return the global teardown function.
return async () => {
await new Promise(done => server.close(done));
};
}
export default globalSetup;
```

@@ -844,3 +847,2 @@

globalSetup: 'global-setup.ts',
globalTeardown: 'global-teardown.ts',
};

@@ -847,0 +849,0 @@ export default config;

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