
Security News
GitHub Actions Supply Chain Attack Puts Thousands of Projects at Risk
A compromised GitHub Action exposed secrets in CI/CD logs, putting thousands of projects at risk and forcing developers to urgently secure their workflows.
qunit-harness
Advanced tools
A library for running qunit tests on a local machine and in the SauceLabs environment.
A library for running qunit tests on a local machine and in the SauceLabs environment.
##Install
$ npm install qunit-harness
##Usage
var QUnitHarness = require('qunit-harness');
function configQunitServerApp (app) {
app.post('/my-custom-request', function (req, res) {
res.end('ok');
});
}
//Local machine testing
var qunitHarness = new QUnitHarness
//specify the path to the tests
.fixtures('/tests/')
//specify qunit server ports
.port(2000) //by default 1335
.crossDomainPort(2001) //by default 1336
//add the index.js script content as <script src='/tested-script.js'> to the head of the test page
.scripts([{ src: '/tested-script.js', path: '/lib/index.js' }])
.css([{ src: '/style.css', path: '/lib/style.css' }])
//extend the qunit server application for test purposes
.configApp(configQunitServerApp)
.create();
//Testing in the Saucelabs environment
//Configure browsers here: https://docs.saucelabs.com/reference/platforms-configurator/
var BROWSERS = [
{
platform: 'Windows 10',
browserName: 'chrome'
},
{
platform: 'Windows 10',
browserName: 'firefox'
},
{
platform: 'Windows 10',
browserName: 'internet explorer',
version: '11.0'
}
];
var SAUCELABS_SETTINGS = {
username: <saucelabs_username>,
accessKey: <saucelabs_accessKey>,
build: 'build',
tags: ['master'],
browsers: BROWSERS,
name: 'qunit tests',
timeout: 180 //sec
};
qunitHarness
.saucelabs(SAUCELABS_SETTINGS)
.tests(['/tests/test1-test.js', '/tests/test2-test.js'])
.run()
.then(function () {
console.log('Tests done');
})
.catch(function (err) {
console.log(err);
});
##QUnit tests ####Get test server hostname
window.QUnitGlobals.hostname; //http://localhost:1335/
window.QUnitGlobals.crossDomainHostname; //http://localhost:1336/
####Get test resource
window.QUnitGlobals.getResourceUrl(pathToResourceFile[, urlAlias])
By default the resource has the http://<hostname>/test-resource?filePath=<resourceFilePath>&base=<currentTestFilePath>
url.
To customize the url, use the urlAlias
argument:
window.QUnitGlobals.getResourceUrl('../data/script.js', 'my-custom-script/script.js');
//returns "http://<hostname>/test-resource/my-custom-script/script.js?filePath=..."
Example:
<!-- data/iframe.html -->
<!DOCTYPE html>
<html>
<head>
<title>Iframe page</title>
<meta charset="utf-8">
</head>
<body>
Some content
</body>
</html>
// tests/test1-test.js
asyncTest('iframe test', function () {
var iframeSrc = window.QUnitGlobals.getResourceUrl('../data/iframe.html', 'iframe.html');
$('<iframe></iframe>').src(iframeSrc).appendTo('body');
//appends an iframe with the url http://<hostname>/test-resource/iframe.html
...
});
Put the testname-test.js
and testname.html
files to the folder with the -test
postfix. Then, the markup from the .html
file will be included into the testname-test.js
test page.
Example:
<!-- tests/markup-test/index.html -->
<div id="#test-element"></div>
// tests/markup-test/index-test.js
test('check element', function () {
ok($('#test-element').length); //success
});
FAQs
A library for running qunit tests on a local machine and in the SauceLabs environment.
The npm package qunit-harness receives a total of 129 weekly downloads. As such, qunit-harness popularity was classified as not popular.
We found that qunit-harness demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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 compromised GitHub Action exposed secrets in CI/CD logs, putting thousands of projects at risk and forcing developers to urgently secure their workflows.
Research
Security News
A malicious Maven package typosquatting a popular library is secretly stealing OAuth credentials on the 15th of each month, putting Java developers at risk.
Security News
Socket and Seal Security collaborate to fix a critical npm overrides bug, resolving a three-year security issue in the JavaScript ecosystem's most popular package manager.