Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
@peakon/mocha-split-tests
Advanced tools
Distribute mocha specs between concurrent test machines / containers on CI based on previously-recorded test runtime
A tool that helps optimizing overall test runtime for big test suites that can be distributed across multiple containers / VMs running in parallel.
This project includes:
mocha
and webdriverio
that are used to record spec runtime stats.As a first step, add @peakon/mocha-split-tests/reporter/mocha
reporter to your mocha tests setup.
As mocha v7 still doesn't support multiple reporters out of the box. So in order to enable @peakon/mocha-split-tests/reporter/mocha
reporter, you have to use a 3rd-party package like mocha-multi. Here is an example config:
// mocha-multi-reporters.json
{
dot: '-',
xunit: {
stdout: '/dev/null',
options: {
output: 'junit/junit.xml'
}
},
'@peakon/mocha-split-tests/reporter/mocha': 'runtime.log'
}
runtime.log
will be generated in project root directory after your run your tests like this:
multi=mocha-multi-reporters.json ./node_modules/.bin/mocha`
Add a runtime reporter to wdio.conf.js
:
reporters: [
"spec",
[
require("@peakon/mocha-split-tests/reporter/wdio"),
{
outputDir: `${yourLogDir}/runtimes`
}
]
];
As WebdriverIO default reporter bahaviour is to generate 1 log file per each capability, spec file pair, you'll end up having a bunch of log files inside outputDir
. For convenience, you can merge them yourself into 1 file (e.g. cat $LOG_DIR/*.log > runtime.log
) or keep them as is.
CLI tool is used on CI environment to generate a list of specs that should be executed by a particular test container / VM.
Usage: mocha-split-tests [options]
Options:
-V, --version output the version number
-t, --total-groups <int> Total number of test runner machines / containers
-g, --group-number <int> Number of group to get tests for (starts from 0)
-r, --runtime-log <pattern> Location of previously recorded test runtimes ( file or pattern for multiple log files)
-f, --file-pattern <pattern> e.g. "test/**/*.spec.js"
-s, --result-separator <symbol> Separator for resulting output (default: " ")
-h, --help output usage information
function getSpecs(totalGroups, groupNumber) {
const { getTestGroup } = require("@peakon/mocha-split-tests");
const testGroup = getTestGroup({
testFilePattern: "./test/**/*.spec.js",
runtimeLogsPattern: ".tmp/test/runtime*.log",
totalGroups,
groupNumber
});
return testGroup.files; //returns an Array of specs
}
npm version <major | minor | patch>
git push --tags
MIT
FAQs
Distribute mocha specs between concurrent test machines / containers on CI based on previously-recorded test runtime
We found that @peakon/mocha-split-tests demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.