Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
atom-jasmine2-test-runner
Advanced tools
By default, Atom runs your tests with Jasmine 1.3 (for more information on testing packages in Atom, please see the Atom Flight Manual). Atom allows you to specify a custom test runner using the atomTestRunner
field in your package.json
, but implementing a custom test runner is not straightforward. This module allows you to transition your specs to Jasmine 2.x with minimal fuss.
$ apm install [--save-dev] atom-jasmine2-test-runner
There is legacy support for transitioning to Jasmine 2.x from 1.3.
By default any specs with a file name matching *-spec-v1.(js|coffee)
will be ran by the default Atom test runner after any new tests are ran.
If you want to use all the default options, simply pass the module name as the atomTestRunner
value in your package.json
:
{
"name": "my-package",
// ...
"atomTestRunner": "atom-jasmine2-test-runner"
}
Note that your package.json
may be cached by Atom's compile cache when running tests with Atom's GUI test runner, so if adding or changing that field doesn't seem to work, try quitting and restarting Atom.
If you'd like to perform more customization of your testing environment, you can create a custom runner while still utilizing atom-jasmine2-test-runner for most of the heavy lifting. First, set atomTestRunner
to a relative path to a file:
{
"name": "my-package",
// ...
"atomTestRunner": "./spec/custom-runner"
}
Then export a test runner created via the atom-jasmine2-test-runner from ./spec/custom-runner.js
:
const { createRunner } = require('atom-jasmine2-test-runner');
// optional options to customize the runner
const extraOptions = {
suffix: "-spec",
legacySuffix: "-spec-v1"
};
const optionalConfigurationFunction = function() {
// If provided, atom-jasmine2-test-runner will call this function before jasmine is started
// so you can do whatever you'd like with the global variables.
// (i.e. add custom matchers, require plugins, etc.)
require("some-jasmine-plugin");
beforeEach(function () {
jasmine.addMatchers({
toBeTheAnswerToTheUltimateQuestionOfLifeTheUniverseAndEverything: function (util, customEqualityTesters) {
return {
compare: function (actual) {
let result = {};
result.pass = util.equals(actual, 42, customEqualityTesters);
const toBeOrNotToBe = (result.pass ? "not to be" : "to be"); // that is the question.
result.message = `Expected ${actual} ${toBeOrNotToBe} the answer to the ultimate question of life, the universe, and everything.`;
return result;
}
};
}
});
});
}
module.exports = createRunner(extraOptions, optionalConfigurationFunction);
createRunner([options,] [callback])
Returns a test runner created with the given options
and callback
. Both parameters are optional. The returned value can be exported from your atomTestRunner
script for Atom to consume.
options
- An object specifying customized options:
reporter
[default: the default reporter]
- Which reporter to use on the terminalsuffix
[default: "-spec"]
- File extension that indicates that the file contains testslegacySuffix
[default: "-spec-v1"]
- File extension that indicates that the file contains Jasmine v1.x testsshowColors
[default: true]
- Colorize output on the terminal.htmlTitle
[default: The name of the package]
- The string to use for the window title in the HTML reportershowEditor
[default: false]
- Add a "Show Editor" tab to minimize the specs so you can see the editor behind ittimeReporter
[default: false]
- Add a reporter that logs the time for each spec/suite. TimeReporterspecHelper
[default: false]
- See Spec HelperstestPaths
[default: './spec' or './test']
- This can be an array of files to test or folders to search for files ending with the suffix
. This does not apply to headless testing using atom --test ./spec
random
[default: false]
- Run your tests in semi-random orderseed
[default: random]
- Sets the randomization seed if randomization is turned onThis will include Atom's spec-helper.
:construction::rotating_light: This is experimental. Some things might not work the way they are supposed to. :rotating_light::construction:
The specHelper
option can be set to true
to enable the spec-helper or you can specify an object enabling only the parts of the spec-helper that you want.
Example:
const options = {
specHelper: {
atom: true,
attachToDom: true,
ci: true,
customMatchers: true,
jasmineFocused: true,
jasmineJson: true,
jasminePass: true,
jasmineTagged: true,
mockClock: true,
mockLocalStorage: true,
profile: true,
set: true,
unspy: true
}
}
These are the possible options for specHelper
atom: true
This will spy on atom.menu.sendToBrowserProcess
and add default config options:
atom.config.set("core.destroyEmptyPanes", false)
atom.config.set("editor.fontFamily", "Courier")
atom.config.set("editor.fontSize", 16)
atom.config.set("editor.autoIndent", false)
attachToDom: true
This will add the function jasmine.attachToDOM(element)
to allow you to easily attach elements to the DOM and it takes care of removing the elements after every test so you don't need to worry about them messing with your other tests. If you want an element to be attached to the DOM for multiple tests you can call jasmine.attachToDOM
in a beforeEach
function.
ci: true
This will throw an error if any focused tests are left when testing in a CI environment.
This will also set jasmine.DEFAULT_TIMEOUT_INTERVAL
to 1 minute in a CI environment.
:rotating_light: This won't do anything unless process.env.CI
is set :rotating_light:
# .travis.yml
env:
global:
- CI="true"
# appveyor.yml
environment:
CI: "true"
# circle.yml
machine:
environment:
CI: "true"
customMatchers: true
This will add the custom matchers from Atom:
toBeInstanceOf
matcher is for the instanceof
operatortoHaveLength
matcher compares against the .length
propertytoExistOnDisk
matcher checks if the file exists in the filesystemtoHaveFocus
matcher checks if the element currently has focustoShow
matcher tests if the element is visible in the domThis will also include the Atom custom version of jasmine-jquery
jasmineFocused: true
Uses jasmine2-focused
This will include jasmine-focused (modified for Jasmine 2.x)
This includes the functions ffdescribe
, fffdescribe
, ffit
, and fffit
.
jasmineJson: true
Uses jasmine2-json
This will include jasmine-json (modified for Jasmine 2.x)
This includes the matcher .toEqualJson(object)
and will give a detailed message on failure.
jasminePass: true
Uses jasmine-pass
This will include a pass()
function similar to Jasmine's fail()
but opposite.
jasmineShouldFail: true
Uses jasmine-should-fail
This will include the functions zdescribe
and zit
to allow you to tell jasmine that these tests should fail.
If these tests pass they will fail and if they fail they will pass but still output their messages as if they failed.
(really only useful for testing a reporter)
jasmineTagged: true
Uses jasmine2-tagged
This will include jasmine-tagged (modified for Jasmine 2.x)
This includes the functions jasmine.setIncludedTags([tags])
and jasmine.includeSpecsWithoutTags(bool)
to allow you to filter tests easily.
mockClock: true
This will mock the setTimeout
and setInterval
functions, as well as a few others, so you can test a process that happens on a timer with the advanceClock
function.
When this is enabled you will need to call jasmine.useRealClock()
if you want to use setTimeout
or setInterval
like usual.
This is similar to calling jasmine.clock().install()
mockLocalStorage: true
This includes the functions mockLocalStorage()
and unmockLocalStorage()
to allow you to mock localStorage.
You will have to call the mockLocalStorage()
function in-order to start mocking localStorage.
pathwatcher: true
This will include the pathwatcher module and try to warn you about any leaking subscriptions for paths after each test
profile: true
This will include the functions measure(description, function)
and profile(description, function)
which will write the time the function takes to console.log
set: true
This will include the methods .jasmineToString()
and .isEqual(Set)
to the Set
prototype.
unspy: true
Uses jasmine-unspy
This will include the function jasmine.unspy(object, method)
to allow you to restore the original function to a spy
describe('Testing', function () {
it('works', function () {
expect(thisVariable).toBeTheAnswerToTheUltimateQuestionOfLifeTheUniverseAndEverything();
});
});
A huge thank you to @BinaryMuse for creating atom-mocha-test-runner and giving me a place to start.
FAQs
Run your Atom package tests using Jasmine 2.x
The npm package atom-jasmine2-test-runner receives a total of 41 weekly downloads. As such, atom-jasmine2-test-runner popularity was classified as not popular.
We found that atom-jasmine2-test-runner 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.