Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
grunt-saucelabs
Advanced tools
Grunt task running tests using Sauce Labs. Supports Qunit and Jasmine tests
A Grunt task for running qunit and jasmine tests using Sauce Labs' Cloudified Browsers.
Grunt is a task-based command line build tool for JavaScript projects, based on nodejs. QUnit is a powerful, easy-to-use JavaScript unit test suite used by the jQuery, jQuery UI and jQuery Mobile projects and is capable of testing any generic JavaScript code, including itself! Sauce Labs offers browser environments on the cloud for testing code.
The grunt-contrib-qunit task runs qunit based test suites on PhantomJS.
The saucelabs-qunit
task is very similar but runs the test suites on the cloudified browser environment provided by Sauce Labs. This ensures that subject of the test runs across different browser environment.
The task also uses Sauce Connect to establish a tunnel between Sauce Labs browsers and the machine running Grunt to load local pages. This is typically useful for testing pages on localhost that are not publically accessible on the internet.
The saucelabs-jasmine
runs jasmine tests in the Sauce Labs browser. The saucelabs-jasmine
task requires jasmine-1.3.0
.
This task is available as a node package and can be installed as npm install grunt-saucelabs
. It can also be included as a devDependency in package.json in your node project.
To use the task in grunt.js
, load the npmTask.
grunt.loadNpmTasks('grunt-saucelabs');
In the grunt.initConfig
, add the configuration that looks like the following
'saucelabs-qunit': {
all: {
options: {
username: 'saucelabs-user-name', // if not provided it'll default to ENV SAUCE_USERNAME (if applicable)
key: 'saucelabs-key', // if not provided it'll default to ENV SAUCE_ACCESS_KEY (if applicable)
urls: ['array or URLs to to load for QUnit'],
concurrency: 'Number of concurrent browsers to test against. Will default to the number of overall browsers specified. Check your plan (free: 2, OSS: 3) and make sure you have got sufficient Sauce Labs concurrency.',
tunneled: 'true (default) / false; false if you choose to skip creating a Sauce connect tunnel.',
tunnelTimeout: 'A numeric value indicating the time to wait before closing all tunnels',
testTimeout: 'Milliseconds to wait before timeout for qunit test per page',
testInterval: 'Milliseconds between retries to check if the tests are completed',
testReadyTimeout: 'Milliseconds to wait until the test-page is ready to be read',
detailedError: 'false (default) / true; if true log detailed test results when a test error occurs',
testname: 'Name of the test',
tags: ['Array of tags'],
browsers: [{
browserName: 'opera'
}],
onTestComplete: function(){
// Called after a qunit unit is done, per page, per browser
// Return true or false, passes or fails the test
// Returning undefined does not alter the test result
// For async return, call
var done = this.async();
setTimeout(function(){
// Return to this test after 1000 milliseconds
done(/*true or false changes the test result, undefined does not alter the result*/);
}, 1000);
}
}
}
}
The configuration of saucelabs-jasmine
are exactly the same.
Note the options object inside a grunt target. This was introduced in grunt-saucelabs-* version 4.0.0 to be compatiable with grunt@0.4.0
The parameters are
process.env.saucekey
. Requiredserver
task from grunt. Requiredthis.async()
in the function. The return of this.async()
is a function that should be called once the async action is completed. OptionalA typical test
task running from Grunt could look like grunt.registerTask('test', ['server', 'qunit', 'saucelabs-qunit']);
This starts a server and then runs the Qunit tests first on PhantomJS and then using the Sauce Labs browsers.
Some projects that use this task are as follows. You can take a look at their GruntFile.js for sample code
If you have a project that uses this plugin, please add it to this list and send a pull request.
Grunt tasks are usually run alongside a continuous integration system. For example, when using Travis, adding the following lines in the package.json ensures that the task is installed with npm install
is run. Registering Sauce Labs in test task using grunt.registerTask('test', ['server', 'saucelabs-qunit']);
ensures that the CI environment runs the tests using npm test
.
To secure the Sauce Key, the CI environment can be configured to provide the key as an environment variable instead of specifying it file. CI Environments like Travis provide ways to add secure variables in the initial configuration.
The IndexedDBShim is a project that uses this plugin in a CI environment. Look at the .travis.yml and the grunt.js for usage example.
FAQs
Grunt task running tests using Sauce Labs. Supports QUnit, Jasmine, Mocha and YUI tests
The npm package grunt-saucelabs receives a total of 2,065 weekly downloads. As such, grunt-saucelabs popularity was classified as popular.
We found that grunt-saucelabs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.