pax_global_header 0000666 0000000 0000000 00000000064 14327321345 0014516 g ustar 00root root 0000000 0000000 52 comment=9fc487f20fee2e3f031d335afafd4c6c4c2e7aff
jasmine-npm-4.5.0/ 0000775 0000000 0000000 00000000000 14327321345 0013742 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/.circleci/ 0000775 0000000 0000000 00000000000 14327321345 0015575 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/.circleci/config.yml 0000664 0000000 0000000 00000004726 14327321345 0017576 0 ustar 00root root 0000000 0000000 # Run tests against supported Node versions
version: 2.1
orbs:
win: circleci/windows@4.1.1
node: circleci/node@5.0.2
executors:
node18:
docker:
- image: cimg/node:18.0.0 # Latest 18.x
working_directory: ~/workspace
node16:
docker:
- image: cimg/node:16.14.2 # Latest 16.x
working_directory: ~/workspace
node14_latest:
docker:
- image: cimg/node:14.17.4 # Latest 14.x
working_directory: ~/workspace
# 14.8 is the first version with top level await in ES modules.
node14_8:
docker:
- image: cimg/node:14.8
working_directory: ~/workspace
# 14.7 is the last version without top level await in ES modules.
node14_7:
docker:
- image: cimg/node:14.7
working_directory: ~/workspace
node12_latest:
docker:
- image: cimg/node:12.22.10 # Latest 12.x
working_directory: ~/workspace
# 12.17 is the first version with dynamic import() of commonjs modules
node12_17:
docker:
- image: cimg/node:12.17
working_directory: ~/workspace
jobs:
test:
parameters:
executor:
type: executor
executor: << parameters.executor >>
steps:
- checkout
- run:
name: Report Node and NPM versions
command: echo "Using Node $(node --version) and NPM $(npm --version)"
- run:
name: Install dependencies
command: npm install
- run:
name: Run tests
command: npm test
test_win:
executor:
name: win/default
shell: bash.exe
steps:
- checkout
- node/install
- run:
name: Report Node and NPM versions
command: echo "Using Node $(node --version) and NPM $(npm --version)"
- run:
name: Install dependencies
command: npm install
- run:
name: Run tests
command: npm test
workflows:
version: 2
push: &push_workflow
jobs:
- test:
matrix:
parameters:
executor:
- node18
- node16
- node14_latest
- node14_8 # first with top level await in ES modules.
- node14_7
- node12_latest
- node12_17 # first with dynamic import() of commonjs modules
- test_win
cron:
<<: *push_workflow
triggers:
- schedule:
# Times are UTC.
cron: "0 10 * * *"
filters:
branches:
only:
- main
jasmine-npm-4.5.0/.editorconfig 0000664 0000000 0000000 00000000173 14327321345 0016420 0 ustar 00root root 0000000 0000000 [*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
[*.{js, json, yml}]
indent_style = space
indent_size = 2
jasmine-npm-4.5.0/.eslintignore 0000664 0000000 0000000 00000000363 14327321345 0016447 0 ustar 00root root 0000000 0000000 spec/fixtures/cjs-syntax-error/syntax_error.js
spec/fixtures/esm-importing-commonjs-syntax-error/syntax_error.js
spec/fixtures/js-loader-import/*.js
spec/fixtures/js-loader-default/*.js
spec/fixtures/esm-reporter-packagejson/customReporter.js
jasmine-npm-4.5.0/.github/ 0000775 0000000 0000000 00000000000 14327321345 0015302 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/.github/CONTRIBUTING.md 0000664 0000000 0000000 00000004023 14327321345 0017532 0 ustar 00root root 0000000 0000000 # Contributing to Jasmine
## Bug reports
Bug reports are welcome, but please help us help you by:
* Searching for existing issues (including closed issues) that are similar to
yours
* Reading the [FAQ](https://jasmine.github.io/pages/faq.html)
* Providing enough information for someone else to to understand and reproduce
the problem. In most cases that includes a clear description of what you're
trying to do, the version of each Jasmine package that you're using, the Node
version, and a minimal but complete code sample that demonstrates the problem.
## Contributing documentation
We welcome efforts to improve Jasmine's documentation. The source code for the
documentation site is at .
## Contributing code
Contributions are welcome, but we don't say yes to every idea. We recommend
opening an issue to propose your idea before starting work, to reduce the risk
of getting a "no" at the pull request stage.
Don't have an idea of your own but want to help solve problems for other
people? That's great! Have a look at the list of
[issues tagged "help needed"](https://github.com/issues?q=is%3Aopen+is%3Aissue+org%3Ajasmine+sort%3Aupdated-desc).
### The nuts and bolts of preparing a pull request
Jasmine is mature software that's downloaded millions of times a week and
supported by a tiny group of people in their free time. Anything that breaks
things for existing users or makes Jasmine harder to maintain is a tough sell.
Before submitting a PR, please check that:
* You aren't introducing any breaking changes
* `npm test` succeeds: tests pass, there are no eslint or prettier errors,
and the exit status is 0
* Your change is well tested: you're reasonably confident that the tests will
fail if somebody breaks your new functionality in the future
* Your code matches the style of the surrounding code
We use Circle CI to test pull requests against a variety of operating systems
and Node versions. Please check back after submitting your PR and make sure
that the build succeeded.
jasmine-npm-4.5.0/.gitignore 0000664 0000000 0000000 00000000235 14327321345 0015732 0 ustar 00root root 0000000 0000000 .idea/
lib-cov
lcov.info
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz
*.sw?
pids
logs
results
build
.grunt
node_modules
package-lock.json
yarn.lock
.DS_Store
jasmine-npm-4.5.0/CODE_OF_CONDUCT.md 0000664 0000000 0000000 00000006241 14327321345 0016544 0 ustar 00root root 0000000 0000000 # Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at jasmine-maintainers@googlegroups.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
jasmine-npm-4.5.0/MIT.LICENSE 0000664 0000000 0000000 00000002045 14327321345 0015400 0 ustar 00root root 0000000 0000000 Copyright (c) 2014-2019 Pivotal Labs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
jasmine-npm-4.5.0/README.md 0000664 0000000 0000000 00000003534 14327321345 0015226 0 ustar 00root root 0000000 0000000 [](https://circleci.com/gh/jasmine/jasmine-npm)
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fjasmine%2Fjasmine-npm?ref=badge_shield)
# The Jasmine Module
The `jasmine` module is a command line interface and supporting code for running
[Jasmine](https://github.com/jasmine/jasmine) specs under Node.
The core of jasmine lives at https://github.com/jasmine/jasmine and is `jasmine-core` in npm.
## Contents
This module allows you to run Jasmine specs for your Node.js code. The output will be displayed in your terminal by default.
## Documentation
https://jasmine.github.io/setup/nodejs.html
## Quick Start
Installation:
```sh
npm install --save-dev jasmine
```
To initialize a project for Jasmine:
```sh
npx jasmine init
````
To seed your project with some examples:
```sh
npx jasmine examples
````
To run your test suite:
```sh
npx jasmine
````
## ES and CommonJS module compatibility
Jasmine is compatible with both ES modules and CommonJS modules. See the
[setup guide](https://jasmine.github.io/setup/nodejs.html) for more information.
## Node version compatibility
Jasmine supports Node 18, 16, 14, and 12.17-12.22.
## Support
Documentation: [jasmine.github.io](https://jasmine.github.io)
Jasmine Mailing list: [jasmine-js@googlegroups.com](mailto:jasmine-js@googlegroups.com)
Twitter: [@jasminebdd](http://twitter.com/jasminebdd)
Please file issues here at Github
Copyright (c) 2008-2017 Pivotal Labs. This software is licensed under the MIT License.
## License
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fjasmine%2Fjasmine-npm?ref=badge_large)
jasmine-npm-4.5.0/RELEASE.md 0000664 0000000 0000000 00000002003 14327321345 0015337 0 ustar 00root root 0000000 0000000 # How to work on a Jasmine Release
## Prepare the release
When ready to release - specs are all green and the stories are done:
1. If this is a major or minor release, publish the corresponding release of
`jasmine-core` as described in that repo's `RELEASE.md`.
2. Create release notes using the Anchorman gem.
3. In `package.json`, update both the package version and the `jasmine-core`
dependency version. This package should depend on the same major and minor
version of `jasmine-core`. For instance, 4.1.1 should depend on
`"jasmine-core": "^4.1.0"`.
4. Commit and push.
5. Wait for Circle CI to go green again.
## Publish the NPM package
1. Create a tag for the version, e.g. `git tag v4.4.0`.
2. Push the tag: `git push --tags`
3. Publish the NPM package: `npm publish`.
### Publish the GitHub release
1. Visit the GitHub releases page and find the tag just published.
2. Paste in a link to the correct release notes for this release.
3. If it is a pre-release, mark it as such.
4. Publish the release.
jasmine-npm-4.5.0/bin/ 0000775 0000000 0000000 00000000000 14327321345 0014512 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/bin/jasmine.js 0000775 0000000 0000000 00000001465 14327321345 0016507 0 ustar 00root root 0000000 0000000 #!/usr/bin/env node
const path = require('path');
const os = require('os');
const Command = require('../lib/command');
const Jasmine = require('../lib/jasmine');
let projectBaseDir = path.resolve();
if (os.platform() === 'win32') {
// Future versions of glob will interpret backslashes as escape sequences on
// all platforms, and Jasmine warns about them. Convert to slashes to avoid
// the warning and future behavior change.
projectBaseDir = projectBaseDir.replace(/\\/g, '/');
}
const jasmine = new Jasmine({ projectBaseDir });
const examplesDir = path.join(path.dirname(require.resolve('jasmine-core')), 'jasmine-core', 'example', 'node_example');
const command = new Command(path.resolve(), examplesDir, {
print: console.log,
platform: os.platform,
});
command.run(jasmine, process.argv.slice(2));
jasmine-npm-4.5.0/lib/ 0000775 0000000 0000000 00000000000 14327321345 0014510 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/lib/command.js 0000664 0000000 0000000 00000022610 14327321345 0016465 0 ustar 00root root 0000000 0000000 const path = require('path');
const fs = require('fs');
exports = module.exports = Command;
const subCommands = {
init: {
description: 'initialize jasmine',
action: initJasmine
},
examples: {
description: 'install examples',
action: installExamples
},
help: {
description: 'show help',
action: help,
alias: '-h'
},
version: {
description: 'show jasmine and jasmine-core versions',
action: version,
alias: '-v'
}
};
function Command(projectBaseDir, examplesDir, deps) {
const {print, platform} = deps;
const isWindows = platform() === 'win32';
this.projectBaseDir = isWindows ? unWindows(projectBaseDir) : projectBaseDir;
this.specDir = `${this.projectBaseDir}/spec`;
const command = this;
this.run = async function(jasmine, commands) {
setEnvironmentVariables(commands);
let commandToRun;
Object.keys(subCommands).forEach(function(cmd) {
const commandObject = subCommands[cmd];
if (commands.indexOf(cmd) >= 0) {
commandToRun = commandObject;
} else if(commandObject.alias && commands.indexOf(commandObject.alias) >= 0) {
commandToRun = commandObject;
}
});
if (commandToRun) {
commandToRun.action({jasmine: jasmine, projectBaseDir: command.projectBaseDir, specDir: command.specDir, examplesDir: examplesDir, print: print});
} else {
const env = parseOptions(commands, isWindows);
if (env.unknownOptions.length > 0) {
process.exitCode = 1;
print('Unknown options: ' + env.unknownOptions.join(', '));
print('');
help({print: print});
} else {
await runJasmine(jasmine, env);
}
}
};
}
function isFileArg(arg) {
return arg.indexOf('--') !== 0 && !isEnvironmentVariable(arg);
}
function parseOptions(argv, isWindows) {
let files = [],
helpers = [],
requires = [],
unknownOptions = [],
color = process.stdout.isTTY || false,
reporter,
configPath,
filter,
failFast,
random,
seed;
for (const arg of argv) {
if (arg === '--no-color') {
color = false;
} else if (arg === '--color') {
color = true;
} else if (arg.match("^--filter=")) {
filter = arg.match("^--filter=(.*)")[1];
} else if (arg.match("^--helper=")) {
helpers.push(arg.match("^--helper=(.*)")[1]);
} else if (arg.match("^--require=")) {
requires.push(arg.match("^--require=(.*)")[1]);
} else if (arg === '--fail-fast') {
failFast = true;
} else if (arg.match("^--random=")) {
random = arg.match("^--random=(.*)")[1] === 'true';
} else if (arg.match("^--seed=")) {
seed = arg.match("^--seed=(.*)")[1];
} else if (arg.match("^--config=")) {
configPath = arg.match("^--config=(.*)")[1];
} else if (arg.match("^--reporter=")) {
reporter = arg.match("^--reporter=(.*)")[1];
} else if (arg === '--') {
break;
} else if (isFileArg(arg)) {
files.push(isWindows ? unWindows(arg) : arg);
} else if (!isEnvironmentVariable(arg)) {
unknownOptions.push(arg);
}
}
return {
color,
configPath,
filter,
failFast,
helpers,
requires,
reporter,
files,
random,
seed,
unknownOptions
};
}
async function runJasmine(jasmine, options) {
await jasmine.loadConfigFile(options.configPath || process.env.JASMINE_CONFIG_PATH);
if (options.failFast !== undefined) {
jasmine.env.configure({
stopSpecOnExpectationFailure: options.failFast,
stopOnSpecFailure: options.failFast
});
}
if (options.seed !== undefined) {
jasmine.seed(options.seed);
}
if (options.random !== undefined) {
jasmine.randomizeTests(options.random);
}
if (options.helpers !== undefined && options.helpers.length) {
jasmine.addMatchingHelperFiles(options.helpers);
}
if (options.requires !== undefined && options.requires.length) {
jasmine.addRequires(options.requires);
}
if (options.reporter !== undefined) {
await registerReporter(options.reporter, jasmine);
}
jasmine.showColors(options.color);
try {
await jasmine.execute(options.files, options.filter);
} catch (error) {
console.error(error);
process.exit(1);
}
}
async function registerReporter(reporterModuleName, jasmine) {
let Reporter;
try {
Reporter = await jasmine.loader.load(resolveReporter(reporterModuleName));
} catch (e) {
throw new Error('Failed to load reporter module '+ reporterModuleName +
'\nUnderlying error: ' + e.stack + '\n(end underlying error)');
}
let reporter;
try {
reporter = new Reporter();
} catch (e) {
throw new Error('Failed to instantiate reporter from '+ reporterModuleName +
'\nUnderlying error: ' + e.stack + '\n(end underlying error)');
}
jasmine.clearReporters();
jasmine.addReporter(reporter);
}
function resolveReporter(nameOrPath) {
if (nameOrPath.startsWith('./') || nameOrPath.startsWith('../')) {
return path.resolve(nameOrPath);
} else {
return nameOrPath;
}
}
function initJasmine(options) {
const print = options.print;
const specDir = options.specDir;
makeDirStructure(path.join(specDir, 'support/'));
if(!fs.existsSync(path.join(specDir, 'support/jasmine.json'))) {
fs.writeFileSync(path.join(specDir, 'support/jasmine.json'), fs.readFileSync(path.join(__dirname, '../lib/examples/jasmine.json'), 'utf-8'));
}
else {
print('spec/support/jasmine.json already exists in your project.');
}
}
function installExamples(options) {
const specDir = options.specDir;
const projectBaseDir = options.projectBaseDir;
const examplesDir = options.examplesDir;
makeDirStructure(path.join(specDir, 'support'));
makeDirStructure(path.join(specDir, 'jasmine_examples'));
makeDirStructure(path.join(specDir, 'helpers', 'jasmine_examples'));
makeDirStructure(path.join(projectBaseDir, 'lib', 'jasmine_examples'));
copyFiles(
path.join(examplesDir, 'spec', 'helpers', 'jasmine_examples'),
path.join(specDir, 'helpers', 'jasmine_examples'),
new RegExp(/[Hh]elper\.js/)
);
copyFiles(
path.join(examplesDir, 'lib', 'jasmine_examples'),
path.join(projectBaseDir, 'lib', 'jasmine_examples'),
new RegExp(/\.js/)
);
copyFiles(
path.join(examplesDir, 'spec', 'jasmine_examples'),
path.join(specDir, 'jasmine_examples'),
new RegExp(/[Ss]pec.js/)
);
}
function help(options) {
const print = options.print;
print('Usage: jasmine [command] [options] [files] [--]');
print('');
print('Commands:');
Object.keys(subCommands).forEach(function(cmd) {
let commandNameText = cmd;
if(subCommands[cmd].alias) {
commandNameText = commandNameText + ',' + subCommands[cmd].alias;
}
print('%s\t%s', lPad(commandNameText, 10), subCommands[cmd].description);
});
print('');
print('If no command is given, jasmine specs will be run');
print('');
print('');
print('Options:');
print('%s\tturn off color in spec output', lPad('--no-color', 18));
print('%s\tforce turn on color in spec output', lPad('--color', 18));
print('%s\tfilter specs to run only those that match the given string', lPad('--filter=', 18));
print('%s\tload helper files that match the given string', lPad('--helper=', 18));
print('%s\tload module that match the given string', lPad('--require=', 18));
print('%s\tstop Jasmine execution on spec failure', lPad('--fail-fast', 18));
print('%s\tpath to your optional jasmine.json', lPad('--config=', 18));
print('%s\tpath to reporter to use instead of the default Jasmine reporter', lPad('--reporter=', 18));
print('%s\tmarker to signal the end of options meant for Jasmine', lPad('--', 18));
print('');
print('The given arguments take precedence over options in your jasmine.json');
print('The path to your optional jasmine.json can also be configured by setting the JASMINE_CONFIG_PATH environment variable');
}
function version(options) {
const print = options.print;
print('jasmine v' + require('../package.json').version);
print('jasmine-core v' + options.jasmine.coreVersion());
}
function lPad(str, length) {
if (str.length >= length) {
return str;
} else {
return lPad(' ' + str, length);
}
}
function copyFiles(srcDir, destDir, pattern) {
const srcDirFiles = fs.readdirSync(srcDir);
srcDirFiles.forEach(function(file) {
if (file.search(pattern) !== -1) {
fs.writeFileSync(path.join(destDir, file), fs.readFileSync(path.join(srcDir, file)));
}
});
}
function makeDirStructure(absolutePath) {
const splitPath = absolutePath.split(path.sep);
splitPath.forEach(function(dir, index) {
if(index > 1) {
const fullPath = path.join(splitPath.slice(0, index).join('/'), dir);
if (!fs.existsSync(fullPath)) {
fs.mkdirSync(fullPath);
}
}
});
}
function isEnvironmentVariable(command) {
const envRegExp = /(.*)=(.*)/;
return command.match(envRegExp);
}
function setEnvironmentVariables(commands) {
commands.forEach(function (command) {
const regExpMatch = isEnvironmentVariable(command);
if(regExpMatch) {
const key = regExpMatch[1];
const value = regExpMatch[2];
process.env[key] = value;
}
});
}
// Future versions of glob will interpret backslashes as escape sequences on
// all platforms, and Jasmine warns about them. Convert to slashes to avoid
// the warning and future behavior change. Should only be called when running
// on Windows.
function unWindows(projectBaseDir) {
return projectBaseDir.replace(/\\/g, '/');
}
jasmine-npm-4.5.0/lib/examples/ 0000775 0000000 0000000 00000000000 14327321345 0016326 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/lib/examples/jasmine.json 0000664 0000000 0000000 00000000305 14327321345 0020645 0 ustar 00root root 0000000 0000000 {
"spec_dir": "spec",
"spec_files": [
"**/*[sS]pec.?(m)js"
],
"helpers": [
"helpers/**/*.?(m)js"
],
"env": {
"stopSpecOnExpectationFailure": false,
"random": true
}
}
jasmine-npm-4.5.0/lib/exit_handler.js 0000664 0000000 0000000 00000000354 14327321345 0017516 0 ustar 00root root 0000000 0000000 class ExitHandler {
constructor(onExit) {
this._onExit = onExit;
}
install() {
process.on('exit', this._onExit);
}
uninstall() {
process.removeListener('exit', this._onExit);
}
}
module.exports = ExitHandler;
jasmine-npm-4.5.0/lib/filters/ 0000775 0000000 0000000 00000000000 14327321345 0016160 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/lib/filters/console_spec_filter.js 0000664 0000000 0000000 00000000426 14327321345 0022541 0 ustar 00root root 0000000 0000000 module.exports = exports = ConsoleSpecFilter;
function ConsoleSpecFilter(options) {
const filterString = options && options.filterString;
const filterPattern = new RegExp(filterString);
this.matches = function(specName) {
return filterPattern.test(specName);
};
}
jasmine-npm-4.5.0/lib/jasmine.js 0000664 0000000 0000000 00000042730 14327321345 0016502 0 ustar 00root root 0000000 0000000 const os = require('os');
const path = require('path');
const util = require('util');
const glob = require('glob');
const Loader = require('./loader');
const ExitHandler = require('./exit_handler');
const ConsoleSpecFilter = require('./filters/console_spec_filter');
/**
* Options for the {@link Jasmine} constructor
* @name JasmineOptions
* @interface
*/
/**
* The path to the project's base directory. This can be absolute or relative
* to the current working directory. If it isn't specified, the current working
* directory will be used.
* @name JasmineOptions#projectBaseDir
* @type (string | undefined)
*/
/**
* Whether to create the globals (describe, it, etc) that make up Jasmine's
* spec-writing interface. If it is set to false, the spec-writing interface
* can be accessed via jasmine-core's `noGlobals` method, e.g.:
*
* `const {describe, it, expect, jasmine} = require('jasmine-core').noGlobals();`
*
* @name JasmineOptions#globals
* @type (boolean | undefined)
* @default true
*/
/**
* @classdesc Configures, builds, and executes a Jasmine test suite
* @param {(JasmineOptions | undefined)} options
* @constructor
* @name Jasmine
* @example
* const Jasmine = require('jasmine');
* const jasmine = new Jasmine();
*/
class Jasmine {
constructor(options) {
options = options || {};
this.loader = options.loader || new Loader();
this.isWindows_ = (options.platform || os.platform)() === 'win32';
const jasmineCore = options.jasmineCore || require('jasmine-core');
if (options.globals === false) {
this.jasmine = jasmineCore.noGlobals().jasmine;
} else {
this.jasmine = jasmineCore.boot(jasmineCore);
}
if (options.projectBaseDir) {
this.validatePath_(options.projectBaseDir);
this.projectBaseDir = options.projectBaseDir;
} else {
this.projectBaseDir = (options.getcwd || path.resolve)();
}
this.specDir = '';
this.specFiles = [];
this.helperFiles = [];
this.requires = [];
/**
* The Jasmine environment.
* @name Jasmine#env
* @readonly
* @see {@link https://jasmine.github.io/api/edge/Env.html|Env}
* @type {Env}
*/
this.env = this.jasmine.getEnv({suppressLoadErrors: true});
this.reportersCount = 0;
this.exit = process.exit;
this.showingColors = true;
this.alwaysListPendingSpecs_ = true;
this.reporter = new module.exports.ConsoleReporter();
this.addReporter(this.reporter);
this.defaultReporterConfigured = false;
/**
* @function
* @name Jasmine#coreVersion
* @return {string} The version of jasmine-core in use
*/
this.coreVersion = function() {
return jasmineCore.version();
};
/**
* Whether to cause the Node process to exit when the suite finishes executing.
*
* @name Jasmine#exitOnCompletion
* @type {boolean}
* @default true
*/
this.exitOnCompletion = true;
}
/**
* Sets whether to randomize the order of specs.
* @function
* @name Jasmine#randomizeTests
* @param {boolean} value Whether to randomize
*/
randomizeTests(value) {
this.env.configure({random: value});
}
/**
* Sets the random seed.
* @function
* @name Jasmine#seed
* @param {number} seed The random seed
*/
seed(value) {
this.env.configure({seed: value});
}
/**
* Sets whether to show colors in the console reporter.
* @function
* @name Jasmine#showColors
* @param {boolean} value Whether to show colors
*/
showColors(value) {
this.showingColors = value;
}
/**
* Sets whether the console reporter should list pending specs even when there
* are failures.
* @name Jasmine#alwaysListPendingSpecs
* @param value {boolean}
*/
alwaysListPendingSpecs(value) {
this.alwaysListPendingSpecs_ = value;
}
/**
* Adds a spec file to the list that will be loaded when the suite is executed.
* @function
* @name Jasmine#addSpecFile
* @param {string} filePath The path to the file to be loaded.
*/
addSpecFile(filePath) {
this.specFiles.push(filePath);
}
/**
* Adds a helper file to the list that will be loaded when the suite is executed.
* @function
* @name Jasmine#addHelperFile
* @param {string} filePath The path to the file to be loaded.
*/
addHelperFile(filePath) {
this.helperFiles.push(filePath);
}
/**
* Add a custom reporter to the Jasmine environment.
* @function
* @name Jasmine#addReporter
* @param {Reporter} reporter The reporter to add
* @see custom_reporter
*/
addReporter(reporter) {
this.env.addReporter(reporter);
this.reportersCount++;
}
/**
* Clears all registered reporters.
* @function
* @name Jasmine#clearReporters
*/
clearReporters() {
this.env.clearReporters();
this.reportersCount = 0;
}
/**
* Provide a fallback reporter if no other reporters have been specified.
* @function
* @name Jasmine#provideFallbackReporter
* @param reporter The fallback reporter
* @see custom_reporter
*/
provideFallbackReporter(reporter) {
this.env.provideFallbackReporter(reporter);
}
/**
* Configures the default reporter that is installed if no other reporter is
* specified.
* @param {ConsoleReporterOptions} options
*/
configureDefaultReporter(options) {
options.print = options.print || function() {
process.stdout.write(util.format.apply(this, arguments));
};
options.showColors = options.hasOwnProperty('showColors') ? options.showColors : true;
this.reporter.setOptions(options);
this.defaultReporterConfigured = true;
}
/**
* Add custom matchers for the current scope of specs.
*
* _Note:_ This is only callable from within a {@link beforeEach}, {@link it}, or {@link beforeAll}.
* @function
* @name Jasmine#addMatchers
* @param {Object} matchers - Keys from this object will be the new matcher names.
* @see custom_matcher
*/
addMatchers(matchers) {
this.env.addMatchers(matchers);
}
async loadSpecs() {
await this._loadFiles(this.specFiles);
}
async loadHelpers() {
await this._loadFiles(this.helperFiles);
}
async _loadFiles(files) {
for (const file of files) {
await this.loader.load(file);
}
}
async loadRequires() {
await this._loadFiles(this.requires);
}
/**
* Loads configuration from the specified file. The file can be a JSON file or
* any JS file that's loadable via require and provides a Jasmine config
* as its default export.
* @param {string} [configFilePath=spec/support/jasmine.json]
* @return Promise
*/
async loadConfigFile(configFilePath) {
if (configFilePath) {
await this.loadSpecificConfigFile_(configFilePath);
} else {
for (const ext of ['json', 'js']) {
try {
await this.loadSpecificConfigFile_(`spec/support/jasmine.${ext}`);
} catch (e) {
if (e.code !== 'MODULE_NOT_FOUND' && e.code !== 'ERR_MODULE_NOT_FOUND') {
throw e;
}
}
}
}
}
async loadSpecificConfigFile_(relativePath) {
const absolutePath = path.resolve(this.projectBaseDir, relativePath);
const config = await this.loader.load(absolutePath);
this.loadConfig(config);
}
/**
* Loads configuration from the specified object.
* @param {Configuration} config
*/
loadConfig(config) {
/**
* @interface Configuration
*/
const envConfig = {...config.env};
/**
* The directory that spec files are contained in, relative to the project
* base directory.
* @name Configuration#spec_dir
* @type string | undefined
*/
this.specDir = config.spec_dir || this.specDir;
this.validatePath_(this.specDir);
/**
* Whether to fail specs that contain no expectations.
* @name Configuration#failSpecWithNoExpectations
* @type boolean | undefined
* @default false
*/
if (config.failSpecWithNoExpectations !== undefined) {
envConfig.failSpecWithNoExpectations = config.failSpecWithNoExpectations;
}
/**
* Whether to stop each spec on the first expectation failure.
* @name Configuration#stopSpecOnExpectationFailure
* @type boolean | undefined
* @default false
*/
if (config.stopSpecOnExpectationFailure !== undefined) {
envConfig.stopSpecOnExpectationFailure = config.stopSpecOnExpectationFailure;
}
/**
* Whether to stop suite execution on the first spec failure.
* @name Configuration#stopOnSpecFailure
* @type boolean | undefined
* @default false
*/
if (config.stopOnSpecFailure !== undefined) {
envConfig.stopOnSpecFailure = config.stopOnSpecFailure;
}
/**
* Whether the default reporter should list pending specs even if there are
* failures.
* @name Configuration#alwaysListPendingSpecs
* @type boolean | undefined
* @default true
*/
if (config.alwaysListPendingSpecs !== undefined) {
this.alwaysListPendingSpecs(config.alwaysListPendingSpecs);
}
/**
* Whether to run specs in a random order.
* @name Configuration#random
* @type boolean | undefined
* @default true
*/
if (config.random !== undefined) {
envConfig.random = config.random;
}
if (config.verboseDeprecations !== undefined) {
envConfig.verboseDeprecations = config.verboseDeprecations;
}
/**
* Specifies how to load files with names ending in .js. Valid values are
* "require" and "import". "import" should be safe in all cases, and is
* required if your project contains ES modules with filenames ending in .js.
* @name Configuration#jsLoader
* @type string | undefined
* @default "require"
*/
if (config.jsLoader === 'import' || config.jsLoader === undefined) {
this.loader.alwaysImport = true;
} else if (config.jsLoader === 'require') {
this.loader.alwaysImport = false;
} else {
throw new Error(`"${config.jsLoader}" is not a valid value for the ` +
'jsLoader configuration property. Valid values are "import", ' +
'"require", and undefined.');
}
if (Object.keys(envConfig).length > 0) {
this.env.configure(envConfig);
}
/**
* An array of helper file paths or {@link https://github.com/isaacs/node-glob#glob-primer|globs}
* that match helper files. Each path or glob will be evaluated relative to
* the spec directory. Helpers are loaded before specs.
* @name Configuration#helpers
* @type string[] | undefined
*/
if(config.helpers) {
this.addMatchingHelperFiles(config.helpers);
}
/**
* An array of module names to load via require() at the start of execution.
* @name Configuration#requires
* @type string[] | undefined
*/
if(config.requires) {
this.addRequires(config.requires);
}
/**
* An array of spec file paths or {@link https://github.com/isaacs/node-glob#glob-primer|globs}
* that match helper files. Each path or glob will be evaluated relative to
* the spec directory.
* @name Configuration#spec_files
* @type string[] | undefined
*/
if(config.spec_files) {
this.addMatchingSpecFiles(config.spec_files);
}
/**
* An array of reporters. Each object in the array will be passed to
* {@link Jasmine#addReporter|addReporter}.
*
* This provides a middle ground between the --reporter= CLI option and full
* programmatic usage. Note that because reporters are objects with methods,
* this option can only be used in JavaScript config files
* (e.g `spec/support/jasmine.js`), not JSON.
* @name Configuration#reporters
* @type Reporter[] | undefined
* @see custom_reporter
*/
if (config.reporters) {
for (const r of config.reporters) {
this.addReporter(r);
}
}
}
addRequires(requires) {
const jasmineRunner = this;
requires.forEach(function(r) {
jasmineRunner.requires.push(r);
});
}
/**
* Sets whether to cause specs to only have one expectation failure.
* @function
* @name Jasmine#stopSpecOnExpectationFailure
* @param {boolean} value Whether to cause specs to only have one expectation
* failure
*/
stopSpecOnExpectationFailure(value) {
this.env.configure({stopSpecOnExpectationFailure: value});
}
/**
* Sets whether to stop execution of the suite after the first spec failure.
* @function
* @name Jasmine#stopOnSpecFailure
* @param {boolean} value Whether to stop execution of the suite after the
* first spec failure
*/
stopOnSpecFailure(value) {
this.env.configure({stopOnSpecFailure: value});
}
async flushOutput() {
// Ensure that all data has been written to stdout and stderr,
// then exit with an appropriate status code. Otherwise, we
// might exit before all previous writes have actually been
// written when Jasmine is piped to another process that isn't
// reading quickly enough.
var streams = [process.stdout, process.stderr];
var promises = streams.map(stream => {
return new Promise(resolve => stream.write('', null, resolve));
});
return Promise.all(promises);
}
/**
* Runs the test suite.
*
* _Note_: Set {@link Jasmine#exitOnCompletion|exitOnCompletion} to false if you
* intend to use the returned promise. Otherwise, the Node process will
* ordinarily exit before the promise is settled.
* @param {Array.} [files] Spec files to run instead of the previously
* configured set
* @param {string} [filterString] Regex used to filter specs. If specified, only
* specs with matching full names will be run.
* @return {Promise} Promise that is resolved when the suite completes.
*/
async execute(files, filterString) {
await this.loadRequires();
await this.loadHelpers();
if (!this.defaultReporterConfigured) {
this.configureDefaultReporter({
showColors: this.showingColors,
alwaysListPendingSpecs: this.alwaysListPendingSpecs_
});
}
if (filterString) {
const specFilter = new ConsoleSpecFilter({
filterString: filterString
});
this.env.configure({specFilter: function(spec) {
return specFilter.matches(spec.getFullName());
}});
}
if (files && files.length > 0) {
this.specDir = '';
this.specFiles = [];
this.addMatchingSpecFiles(files);
}
await this.loadSpecs();
const prematureExitHandler = new ExitHandler(() => this.exit(4));
prematureExitHandler.install();
const overallResult = await this.env.execute();
await this.flushOutput();
prematureExitHandler.uninstall();
if (this.exitOnCompletion) {
this.exit(exitCodeForStatus(overallResult.overallStatus));
}
return overallResult;
}
validatePath_(path) {
if (this.isWindows_ && path.includes('\\')) {
const fixed = path.replace(/\\/g, '/');
console.warn('Backslashes in ' +
'file paths behave inconsistently between platforms and might not be ' +
'treated as directory separators in a future version. Consider ' +
`changing ${path} to ${fixed}.`);
}
}
}
/**
* Adds files that match the specified patterns to the list of spec files.
* @function
* @name Jasmine#addMatchingSpecFiles
* @param {Array} patterns An array of spec file paths
* or {@link https://github.com/isaacs/node-glob#glob-primer|globs} that match
* spec files. Each path or glob will be evaluated relative to the spec directory.
*/
Jasmine.prototype.addMatchingSpecFiles = addFiles('specFiles');
/**
* Adds files that match the specified patterns to the list of helper files.
* @function
* @name Jasmine#addMatchingHelperFiles
* @param {Array} patterns An array of helper file paths
* or {@link https://github.com/isaacs/node-glob#glob-primer|globs} that match
* helper files. Each path or glob will be evaluated relative to the spec directory.
*/
Jasmine.prototype.addMatchingHelperFiles = addFiles('helperFiles');
function addFiles(kind) {
return function (files) {
for (const f of files) {
this.validatePath_(f);
}
const jasmineRunner = this;
const fileArr = this[kind];
const {includeFiles, excludeFiles} = files.reduce(function(ongoing, file) {
const hasNegation = file.startsWith('!');
if (hasNegation) {
file = file.substring(1);
}
if (!path.isAbsolute(file)) {
file = path.join(jasmineRunner.projectBaseDir, jasmineRunner.specDir, file);
}
return {
includeFiles: ongoing.includeFiles.concat(!hasNegation ? [file] : []),
excludeFiles: ongoing.excludeFiles.concat(hasNegation ? [file] : [])
};
}, { includeFiles: [], excludeFiles: [] });
includeFiles.forEach(function(file) {
const filePaths = glob
.sync(file, { ignore: excludeFiles })
.filter(function(filePath) {
// glob will always output '/' as a segment separator but the fileArr may use \ on windows
// fileArr needs to be checked for both versions
return fileArr.indexOf(filePath) === -1 && fileArr.indexOf(path.normalize(filePath)) === -1;
});
filePaths.forEach(function(filePath) {
fileArr.push(filePath);
});
});
};
}
function exitCodeForStatus(status) {
switch (status) {
case 'passed':
return 0;
case 'incomplete':
return 2;
case 'failed':
return 3;
default:
console.error(`Unrecognized overall status: ${status}`);
return 1;
}
}
module.exports = Jasmine;
module.exports.ConsoleReporter = require('./reporters/console_reporter');
jasmine-npm-4.5.0/lib/loader.js 0000664 0000000 0000000 00000015421 14327321345 0016317 0 ustar 00root root 0000000 0000000 const path = require('path');
class Loader {
constructor(options) {
options = options || {};
this.require_ = options.requireShim || requireShim;
this.import_ = options.importShim || importShim;
this.resolvePath_ = options.resolvePath || path.resolve.bind(path);
this.alwaysImport = true;
}
load(modulePath) {
if ((this.alwaysImport && !modulePath.endsWith('.json')) || modulePath.endsWith('.mjs')) {
let importSpecifier;
if (modulePath.indexOf(path.sep) === -1 && modulePath.indexOf('/') === -1) {
importSpecifier = modulePath;
} else {
// The ES module spec requires import paths to be valid URLs. As of v14,
// Node enforces this on Windows but not on other OSes. On OS X, import
// paths that are URLs must not contain parent directory references.
importSpecifier = `file://${this.resolvePath_(modulePath)}`;
}
return this.import_(importSpecifier)
.then(
mod => mod.default,
e => {
if (e.code === 'ERR_UNKNOWN_FILE_EXTENSION') {
// Extension isn't supported by import, e.g. .jsx. Fall back to
// require(). This could lead to confusing error messages if someone
// tries to use ES module syntax without transpiling in a file with
// an unsupported extension, but it shouldn't break anything and it
// should work well in the normal case where the file is loadable
// as a CommonJS module, either directly or with the help of a
// loader like `@babel/register`.
return this.require_(modulePath);
} else {
return Promise.reject(fixupImportException(e, modulePath));
}
}
);
} else {
return new Promise(resolve => {
const result = this.require_(modulePath);
resolve(result);
});
}
}
}
function requireShim(modulePath) {
return require(modulePath);
}
function importShim(modulePath) {
return import(modulePath);
}
function fixupImportException(e, importedPath) {
// When an ES module has a syntax error, the resulting exception does not
// include the filename, which the user will need to debug the problem. We
// need to fix those up to include the filename. However, other kinds of load-
// time errors *do* include the filename and usually the line number. We need
// to leave those alone.
//
// Some examples of load-time errors that we need to deal with:
// 1. Syntax error in an ESM spec:
// SyntaxError: missing ) after argument list
// at Loader.moduleStrategy (node:internal/modules/esm/translators:147:18)
// at async link (node:internal/modules/esm/module_job:64:21)
//
// 2. Syntax error in an ES module imported from an ESM spec. This is exactly
// the same as #1: there is no way to tell which file actually has the syntax
// error.
//
// 3. Syntax error in a CommonJS module imported by an ES module:
// /path/to/commonjs_with_syntax_error.js:2
//
//
//
// SyntaxError: Unexpected end of input
// at Object.compileFunction (node:vm:355:18)
// at wrapSafe (node:internal/modules/cjs/loader:1038:15)
// at Module._compile (node:internal/modules/cjs/loader:1072:27)
// at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
// at Module.load (node:internal/modules/cjs/loader:988:32)
// at Function.Module._load (node:internal/modules/cjs/loader:828:14)
// at ModuleWrap. (node:internal/modules/esm/translators:201:29)
// at ModuleJob.run (node:internal/modules/esm/module_job:175:25)
// at async Loader.import (node:internal/modules/esm/loader:178:24)
// at async file:///path/to/esm_that_imported_cjs.mjs:2:11
//
// Note: For Jasmine's purposes, case 3 only occurs in Node >= 14.8. Older
// versions don't support top-level await, without which it's not possible to
// load a CommonJS module from an ES module at load-time. The entire content
// above, including the file path and the three blank lines, is part of the
// error's `stack` property. There may or may not be any stack trace after the
// SyntaxError line, and if there's a stack trace it may or may not contain
// any useful information.
//
// 4. Any other kind of exception thrown at load time
//
// Error: nope
// at Object. (/path/to/file_throwing_error.js:1:7)
// at Module._compile (node:internal/modules/cjs/loader:1108:14)
// at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
// at Module.load (node:internal/modules/cjs/loader:988:32)
// at Function.Module._load (node:internal/modules/cjs/loader:828:14)
// at ModuleWrap. (node:internal/modules/esm/translators:201:29)
// at ModuleJob.run (node:internal/modules/esm/module_job:175:25)
// at async Loader.import (node:internal/modules/esm/loader:178:24)
// at async file:///path_to_file_importing_broken_file.mjs:1:1
//
// We need to replace the error with a useful one in cases 1 and 2, but not in
// cases 3 and 4. Distinguishing among them can be tricky. Simple heuristics
// like checking the stack trace for the name of the file we imported fail
// because it often shows up even when the error was elsewhere, e.g. at the
// bottom of the stack traces in the examples for cases 3 and 4 above. To add
// to the fun, file paths in errors on Windows can be either Windows style
// paths (c:\path\to\file.js) or URLs (file:///c:/path/to/file.js).
if (!(e instanceof SyntaxError)) {
return e;
}
const escapedWin = escapeStringForRegexp(importedPath.replace(/\//g, '\\'));
const windowsPathRegex = new RegExp('[a-zA-z]:\\\\([^\\s]+\\\\|)' + escapedWin);
const windowsUrlRegex = new RegExp('file:///[a-zA-z]:\\\\([^\\s]+\\\\|)' + escapedWin);
const anyUnixPathFirstLineRegex = /^\/[^\s:]+:\d/;
const anyWindowsPathFirstLineRegex = /^[a-zA-Z]:(\\[^\s\\:]+)+:/;
if (e.message.indexOf(importedPath) !== -1
|| e.stack.indexOf(importedPath) !== -1
|| e.stack.match(windowsPathRegex) || e.stack.match(windowsUrlRegex)
|| e.stack.match(anyUnixPathFirstLineRegex)
|| e.stack.match(anyWindowsPathFirstLineRegex)) {
return e;
} else {
return new Error(`While loading ${importedPath}: ${e.constructor.name}: ${e.message}`);
}
}
// Adapted from Sindre Sorhus's escape-string-regexp (MIT license)
function escapeStringForRegexp(string) {
// Escape characters with special meaning either inside or outside character sets.
// Use a simple backslash escape when it’s always valid, and a `\xnn` escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
return string
.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
.replace(/-/g, '\\x2d');
}
module.exports = Loader;
jasmine-npm-4.5.0/lib/reporters/ 0000775 0000000 0000000 00000000000 14327321345 0016535 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/lib/reporters/console_reporter.js 0000664 0000000 0000000 00000017470 14327321345 0022470 0 ustar 00root root 0000000 0000000 module.exports = exports = ConsoleReporter;
/**
* @classdesc A reporter that prints spec and suite results to the console.
* A ConsoleReporter is installed by default.
*
* @constructor
* @example
* const {ConsoleReporter} = require('jasmine');
* const reporter = new ConsoleReporter();
*/
function ConsoleReporter() {
let print = function() {},
showColors = false,
specCount,
executableSpecCount,
failureCount,
failedSpecs = [],
pendingSpecs = [],
alwaysListPendingSpecs = true,
ansi = {
green: '\x1B[32m',
red: '\x1B[31m',
yellow: '\x1B[33m',
none: '\x1B[0m'
},
failedSuites = [],
stackFilter = stack => stack;
/**
* Configures the reporter.
* @function
* @name ConsoleReporter#setOptions
* @param {ConsoleReporterOptions} options
*/
this.setOptions = function(options) {
if (options.print) {
print = options.print;
}
/**
* @interface ConsoleReporterOptions
*/
/**
* Whether to colorize the output
* @name ConsoleReporterOptions#showColors
* @type Boolean|undefined
* @default false
*/
showColors = options.showColors || false;
if (options.stackFilter) {
stackFilter = options.stackFilter;
}
/**
* A function that takes a random seed and returns the command to reproduce
* that seed. Use this to customize the output when using ConsoleReporter
* in a different command line tool.
* @name ConsoleReporterOptions#randomSeedReproductionCmd
* @type Function|undefined
*/
if (options.randomSeedReproductionCmd) {
this.randomSeedReproductionCmd = options.randomSeedReproductionCmd;
}
/**
* Whether to list pending specs even if there are failures.
* @name ConsoleReporterOptions#alwaysListPendingSpecs
* @type Boolean|undefined
* @default true
*/
if (options.alwaysListPendingSpecs !== undefined) {
alwaysListPendingSpecs = options.alwaysListPendingSpecs;
}
};
this.jasmineStarted = function(options) {
specCount = 0;
executableSpecCount = 0;
failureCount = 0;
if (options && options.order && options.order.random) {
print('Randomized with seed ' + options.order.seed);
printNewline();
}
print('Started');
printNewline();
};
this.jasmineDone = function(result) {
if (result.failedExpectations) {
failureCount += result.failedExpectations.length;
}
printNewline();
printNewline();
if (failedSpecs.length > 0) {
print('Failures:');
}
for (let i = 0; i < failedSpecs.length; i++) {
specFailureDetails(failedSpecs[i], i + 1);
}
for(let i = 0; i < failedSuites.length; i++) {
suiteFailureDetails(failedSuites[i]);
}
if (result && result.failedExpectations && result.failedExpectations.length > 0) {
suiteFailureDetails({ fullName: 'top suite', ...result });
}
if (alwaysListPendingSpecs || result.overallStatus === 'passed') {
if (pendingSpecs.length > 0) {
print("Pending:");
}
for (let i = 0; i < pendingSpecs.length; i++) {
pendingSpecDetails(pendingSpecs[i], i + 1);
}
}
if(specCount > 0) {
printNewline();
if(executableSpecCount !== specCount) {
print('Ran ' + executableSpecCount + ' of ' + specCount + plural(' spec', specCount));
printNewline();
}
let specCounts = executableSpecCount + ' ' + plural('spec', executableSpecCount) + ', ' +
failureCount + ' ' + plural('failure', failureCount);
if (pendingSpecs.length) {
specCounts += ', ' + pendingSpecs.length + ' pending ' + plural('spec', pendingSpecs.length);
}
print(specCounts);
} else {
print('No specs found');
}
printNewline();
const seconds = result ? result.totalTime / 1000 : 0;
print('Finished in ' + seconds + ' ' + plural('second', seconds));
printNewline();
if (result && result.overallStatus === 'incomplete') {
print('Incomplete: ' + result.incompleteReason);
printNewline();
}
if (result && result.order && result.order.random) {
print('Randomized with seed ' + result.order.seed);
print(' (' + this.randomSeedReproductionCmd(result.order.seed) + ')');
printNewline();
}
};
this.randomSeedReproductionCmd = function(seed) {
return 'jasmine --random=true --seed=' + seed;
};
this.specDone = function(result) {
specCount++;
if (result.status == 'pending') {
pendingSpecs.push(result);
executableSpecCount++;
print(colored('yellow', '*'));
return;
}
if (result.status == 'passed') {
executableSpecCount++;
print(colored('green', '.'));
return;
}
if (result.status == 'failed') {
failureCount++;
failedSpecs.push(result);
executableSpecCount++;
print(colored('red', 'F'));
}
};
this.suiteDone = function(result) {
if (result.failedExpectations && result.failedExpectations.length > 0) {
failureCount++;
failedSuites.push(result);
}
};
return this;
function printNewline() {
print('\n');
}
function colored(color, str) {
return showColors ? (ansi[color] + str + ansi.none) : str;
}
function plural(str, count) {
return count == 1 ? str : str + 's';
}
function repeat(thing, times) {
const arr = [];
for (let i = 0; i < times; i++) {
arr.push(thing);
}
return arr;
}
function indent(str, spaces) {
const lines = (str || '').split('\n');
const newArr = [];
for (let i = 0; i < lines.length; i++) {
newArr.push(repeat(' ', spaces).join('') + lines[i]);
}
return newArr.join('\n');
}
function specFailureDetails(result, failedSpecNumber) {
printNewline();
print(failedSpecNumber + ') ');
print(result.fullName);
printFailedExpectations(result);
if (result.debugLogs) {
printNewline();
print(indent('Debug logs:', 2));
printNewline();
for (const entry of result.debugLogs) {
print(indent(`${entry.timestamp}ms: ${entry.message}`, 4));
printNewline();
}
}
}
function suiteFailureDetails(result) {
printNewline();
print('Suite error: ' + result.fullName);
printFailedExpectations(result);
}
function printFailedExpectations(result) {
for (let i = 0; i < result.failedExpectations.length; i++) {
const failedExpectation = result.failedExpectations[i];
printNewline();
print(indent('Message:', 2));
printNewline();
print(colored('red', indent(failedExpectation.message, 4)));
printNewline();
print(indent('Stack:', 2));
printNewline();
print(indent(stackFilter(failedExpectation.stack), 4));
}
// When failSpecWithNoExpectations = true and a spec fails because of no expectations found,
// jasmine-core reports it as a failure with no message.
//
// Therefore we assume that when there are no failed or passed expectations,
// the failure was because of our failSpecWithNoExpectations setting.
//
// Same logic is used by jasmine.HtmlReporter, see https://github.com/jasmine/jasmine/blob/main/src/html/HtmlReporter.js
if (result.failedExpectations.length === 0 &&
result.passedExpectations.length === 0) {
printNewline();
print(indent('Message:', 2));
printNewline();
print(colored('red', indent('Spec has no expectations', 4)));
}
printNewline();
}
function pendingSpecDetails(result, pendingSpecNumber) {
printNewline();
printNewline();
print(pendingSpecNumber + ') ');
print(result.fullName);
printNewline();
let pendingReason = "No reason given";
if (result.pendingReason && result.pendingReason !== '') {
pendingReason = result.pendingReason;
}
print(indent(colored('yellow', pendingReason), 2));
printNewline();
}
}
jasmine-npm-4.5.0/package.json 0000664 0000000 0000000 00000002567 14327321345 0016242 0 ustar 00root root 0000000 0000000 {
"name": "jasmine",
"description": "CLI for Jasmine, a simple JavaScript testing framework for browsers and Node",
"homepage": "http://jasmine.github.io/",
"keywords": [
"test",
"testing",
"jasmine",
"tdd",
"bdd"
],
"license": "MIT",
"version": "4.5.0",
"repository": {
"type": "git",
"url": "https://github.com/jasmine/jasmine-npm"
},
"scripts": {
"test": "node ./bin/jasmine.js",
"posttest": "eslint \"bin/**/*.js\" \"lib/**/*.js\" \"spec/**/*.js\""
},
"exports": "./lib/jasmine.js",
"files": [
"bin",
"lib",
"MIT.LICENSE",
"package.json",
"README.md"
],
"dependencies": {
"glob": "^7.1.6",
"jasmine-core": "^4.5.0"
},
"bin": "./bin/jasmine.js",
"main": "./lib/jasmine.js",
"devDependencies": {
"eslint": "^6.8.0",
"shelljs": "^0.8.3",
"slash": "^3.0.0",
"temp": "^0.9.4"
},
"eslintConfig": {
"parserOptions": {
"ecmaVersion": 11
},
"rules": {
"no-unused-vars": [
"error",
{
"args": "none"
}
],
"block-spacing": "error",
"func-call-spacing": [
"error",
"never"
],
"key-spacing": "error",
"no-tabs": "error",
"no-whitespace-before-property": "error",
"semi": [
"error",
"always"
],
"space-before-blocks": "error"
}
}
}
jasmine-npm-4.5.0/release_notes/ 0000775 0000000 0000000 00000000000 14327321345 0016572 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/release_notes/2.1.0.md 0000664 0000000 0000000 00000001730 14327321345 0017553 0 ustar 00root root 0000000 0000000 # Jasmine NPM 2.1.0 Release Notes
## Summary
This release updates the jasmine-core dependency to 2.1.0. See the
[jasmine-core release notes](https://github.com/pivotal/jasmine/blob/master/release_notes/2.1.0.md)
for more information.
## Changes
* Stop using util.print as default print option.
* Make the grunt task that runs the jasmine specs available by moving it to the `tasks` dir
* Add cleaned up ConsoleReporter from jasmine-core to the npm.
## Pull Requests and Issues
- Split paths with path.sep and parse arguments in a more compatible way.
- Merges [#6](http://github.com/pivotal/jasmine-npm/issues/6) from @briandipalma
- Allow the jasmine command to run only a specified set of files.
- Fixes [#2](http://github.com/pivotal/jasmine-npm/issues/2)
- Add ability to load jasmine config from a javascript object
- Merges [#1](http://github.com/pivotal/jasmine-npm/issues/1)
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/2.1.1.md 0000664 0000000 0000000 00000001112 14327321345 0017546 0 ustar 00root root 0000000 0000000 # Jasmine NPM 2.1.1 Release Notes
## Summary
This release improves the output of the ConsoleReporter.
## Changes
* ConsoleReporter - Add red color to failure messages, add headings for message and stack, add failed spec number
* Update travis badge
* Add .idea/ to gitignore.
## Pull Requests and Issues
- Improve error formatting
- Fixes stack trace of Issue [#4](https://github.com/jasmine/jasmine-npm/issues/4), Merges [#13](https://github.com/jasmine/jasmine-npm/pull/13) from @wendorf
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_ jasmine-npm-4.5.0/release_notes/2.2.0.md 0000664 0000000 0000000 00000000756 14327321345 0017563 0 ustar 00root root 0000000 0000000 # Jasmine NPM 2.2.0 Release Notes
## Summary
This release updates the jasmine-core dependency to 2.2.0. See the
[jasmine-core release notes](https://github.com/pivotal/jasmine/blob/master/release_notes/2.2.0.md)
for more information.
## Changes
* Show pending specs at the end of the suite
* Don't package node_modules and release_notes directories
* Uses more realistic folder structure for examples
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/2.2.1.md 0000664 0000000 0000000 00000000434 14327321345 0017555 0 ustar 00root root 0000000 0000000 # Jasmine NPM 2.2.1 Release Notes
## Pull Requests & Issues
* Use exit module instead of process.exit for Windows workaround
- Fixes [#20](https://github.com/jasmine/jasmine-npm/issues/20)
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/2.3.0.md 0000664 0000000 0000000 00000004064 14327321345 0017560 0 ustar 00root root 0000000 0000000 # Jasmine NPM 2.3.0 Release Notes
## Summary
This release updates the jasmine-core dependency to 2.3.0. See the
[jasmine-core release notes](https://github.com/pivotal/jasmine/blob/master/release_notes/2.3.0.md)
for more information.
## Changes
* Move mention of default command up near other commands in help
* Document how to specify path to config file
* Add docs for filter and stop spec execution
* Allows the user to specify stop on execution behavior with a CLI param.
* Gives the user the ability to stop execution on failure.
* Adds version command to show the jasmine and jasmine-core versions.
* Deprecates passing an onComplete to ConsoleReporter and as an option to configureDefaultReporter
* Adds jasmine.onComplete that defines a callback for the exit code reporter to call
## Pull Requests & Issues
* Use the exit module only in Windows with node version below v0.12.0. Use process.exit otherwise
- Fixes [#40](https://github.com/jasmine/jasmine-npm/issues/40)
- Fixes [#36](https://github.com/jasmine/jasmine-npm/issues/36)
* Add -v and -h aliases to the CLI.
- Fixes [#19](https://github.com/jasmine/jasmine-npm/issues/19)
* Add filter by spec name
- Merge [#35](https://github.com/jasmine/jasmine-npm/issues/35) from @just-boris
* Update package.json license
- Merge [#34](https://github.com/jasmine/jasmine-npm/issues/34) from @mikaturunen
* Don't output ANSI escape sequences if stdout is not a terminal
- Merge [#33](https://github.com/jasmine/jasmine-npm/issues/33) from @sgravrock
* jasmine command only adds a default reporter if no other reporter is added.
- Fixes [#28](https://github.com/jasmine/jasmine-npm/issues/28)
* Load helper files even if files are specified on the command line
- Fixes [#21](https://github.com/jasmine/jasmine-npm/issues/21)
- Fixes [#28](https://github.com/jasmine/jasmine-npm/issues/28)
* Allow custom stackFilter function
- Merge [#27](https://github.com/jasmine/jasmine-npm/issues/27) from @hankduan
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/2.3.1.md 0000664 0000000 0000000 00000000631 14327321345 0017555 0 ustar 00root root 0000000 0000000 # Jasmine NPM 2.3.1 Release Notes
## Summary
This patch release fixes a breaking change made in 2.3.0 related to default exiting of the process.
## Changes
## Pull Requests & Issues
* Only use the default exiting if the default reporter is used.
- Fixes [#43](https://github.com/jasmine/jasmine-npm/issues/43)
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/2.3.2.md 0000664 0000000 0000000 00000001072 14327321345 0017556 0 ustar 00root root 0000000 0000000 # Jasmine NPM 2.3.2 Release Notes
## Pull Requests & Issues
* Use JASMINE_CONFIG_PATH env in grunt task
- Merges [#50](https://github.com/jasmine/jasmine-npm/issues/50) from @nesQuick
* Add link to docs for jasmine.json
- Fixes [#49](https://github.com/jasmine/jasmine-npm/issues/49)
* Merge pull request #48 from LJWall/count-disabled
Report "Ran X of Y specs" if some are disabled.
- Merges [#48](https://github.com/jasmine/jasmine-npm/issues/48) from @ljwall
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/2.4.0.md 0000664 0000000 0000000 00000000634 14327321345 0017560 0 ustar 00root root 0000000 0000000 # Jasmine NPM 2.4.0 Release Notes
## Summary
This release updates the jasmine-core dependency to 2.4.0. See the
[jasmine-core release notes](https://github.com/pivotal/jasmine/blob/master/release_notes/2.4.0.md)
for more information.
## Changes
* Enable the --random and --seed cli flags
- Merges #55 from @marcioj
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/2.4.1.md 0000664 0000000 0000000 00000000421 14327321345 0017553 0 ustar 00root root 0000000 0000000 # Jasmine NPM 2.4.1 Release Notes
## Pull Requests & Issues
* Remove comments and generally fix example json file
- Fixes [#60](https://github.com/jasmine/jasmine-npm/issues/60)
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/2.5.0.md 0000664 0000000 0000000 00000003051 14327321345 0017555 0 ustar 00root root 0000000 0000000 # Jasmine NPM 2.5.0 Release Notes
## Summary
This release updates the jasmine-core dependency to 2.5.0. See the
[jasmine-core release notes](https://github.com/pivotal/jasmine/blob/master/release_notes/2.5.0.md)
for more information.
## Changes
* Report errors in global afterAlls
* Retrieve the jasmine-core version through the interface
* Run CI against multiple node versions
## Pull Requests & Issues
* Added travis ci support for node 6
- Merges [#79](https://github.com/jasmine/jasmine-npm/issues/79) from @amilajack
* Added better install method to readme
- Merges [#80](https://github.com/jasmine/jasmine-npm/issues/80) from @amilajack
* Use jasmine-core's fallback reporter
- Merges [#67](https://github.com/jasmine/jasmine-npm/issues/67) from @mauricioborges
- Fixes [#66](https://github.com/jasmine/jasmine-npm/issues/66)
* Allow to run without jasmine.json
- Merges [#74](https://github.com/jasmine/jasmine-npm/issues/74) from @m7r
* Default spec_dir if not provided
- Merges [#70](https://github.com/jasmine/jasmine-npm/issues/70) from @dflynn15
- Fixes [#69](https://github.com/jasmine/jasmine-npm/issues/69)
* Proper handling of randomization args in config and command line
- Merges [#65](https://github.com/jasmine/jasmine-npm/issues/65) from @marcioj
* Resolve examples folder dynamically.
- Merges [#64](https://github.com/jasmine/jasmine-npm/issues/64) from @danielsiwiec
- Fixes [#63](https://github.com/jasmine/jasmine-npm/issues/63)
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/2.5.1.md 0000664 0000000 0000000 00000001435 14327321345 0017562 0 ustar 00root root 0000000 0000000 # Jasmine NPM 2.5.1 Release Notes
## Summary
This release updates the jasmine-core dependency to 2.5.1. See the
[jasmine-core release notes](https://github.com/pivotal/jasmine/blob/master/release_notes/2.5.1.md)
for more information.
## Pull Requests & Issues
* Update glob dependency
- Fixes [#78](https://github.com/jasmine/jasmine-npm/issues/78)
- Fixes [jasmine/jasmine#1148](https://github.com/jasmine/jasmine/issues/1148)
* Only use the default exiting if the default reporter is used
- Merges [#89](https://github.com/jasmine/jasmine-npm/issues/89) from @flore77
* Update link to documentation in README.md
- Merges [#87](https://github.com/jasmine/jasmine-npm/issues/87) from @gkalpak
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/2.5.2.md 0000664 0000000 0000000 00000000622 14327321345 0017560 0 ustar 00root root 0000000 0000000 # Jasmine NPM 2.5.2 Release Notes
## Changes
* Register ConsoleReporter immediately upon creation so it can be easily cleared
- Fixes [#88](https://github.com/jasmine/jasmine-npm/issues/88)
* Use default reporter in own tests
- Merges [#88](https://github.com/jasmine/jasmine-npm/issues/88) from bcaudan
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/2.5.3.md 0000664 0000000 0000000 00000001142 14327321345 0017557 0 ustar 00root root 0000000 0000000 # Jasmine NPM 2.5.3 Release Notes
## Pull Requests & Issues
* A bunch of fixes to make the default reporter work better and accept the right configurations
- Merge #98 from @cnishina
- Fixes #95
- Merges #100 from @tomv564
* adding license file
- Merges #101 from @julka
* default console reporter hangs sometimes
- Merge #84 from @ybian
- Fixes #83
* Enable regex filter by omitting automatic escaping
- Merge #76 from @aaalsaleh
* Allow adding a helper with a cli argument
- Merges #75 from @m7r
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/2.6.0.md 0000664 0000000 0000000 00000001314 14327321345 0017556 0 ustar 00root root 0000000 0000000 # Jasmine NPM 2.6.0 Release Notes
## Summary
This release updates the jasmine-core dependency to 2.6.0. See the
[jasmine-core release notes](https://github.com/pivotal/jasmine/blob/master/release_notes/2.6.0.md)
for more information.
## Pull Requests & Issues
* Expose `closeReporters` methos in the wrapper
- Merges #114 from @lonelyelk
- Fixes jasmine/jasmine#1228
* Try to detect a `exit` being called inside the suite
- Fixes jasmine/jasmine#1273
* Option to specify path to your jasmine.json
- Merges #107 from @bcaudan
- Fixes #85
* Reject unknown CLI options
- Merges #108 from @bcaudan
- Fixes #53
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/2.7.0.md 0000664 0000000 0000000 00000001272 14327321345 0017562 0 ustar 00root root 0000000 0000000 # Jasmine NPM 2.7.0 Release Notes
## Summary
This release updates the jasmine-core dependency to 2.7.0. See the
[jasmine-core release notes](https://github.com/pivotal/jasmine/blob/master/release_notes/2.7.0.md)
for more information.
## Pull Requests & Issues
* Report the random seed at the beginning and end of execution to allow users to reproduce seed-dependent Jasmine crashes.
- Merges [#120](https://github.com/jasmine/jasmine-npm/issues/120) from @sgravrock
* Fix linebreak between jasmine config examples.
- Merges [#122](https://github.com/jasmine/jasmine-npm/issues/122) from @donmccurdy
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/2.8.0.md 0000664 0000000 0000000 00000000507 14327321345 0017563 0 ustar 00root root 0000000 0000000 # Jasmine NPM 2.8.0 Release Notes
## Summary
This release updates the jasmine-core dependency to 2.8.0. See the
[jasmine-core release notes](https://github.com/pivotal/jasmine/blob/master/release_notes/2.8.0.md)
for more information.
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/2.9.0.md 0000664 0000000 0000000 00000000507 14327321345 0017564 0 ustar 00root root 0000000 0000000 # Jasmine NPM 2.9.0 Release Notes
## Summary
This release updates the jasmine-core dependency to 2.9.0. See the
[jasmine-core release notes](https://github.com/pivotal/jasmine/blob/master/release_notes/2.9.0.md)
for more information.
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/2.99.md 0000664 0000000 0000000 00000000556 14327321345 0017523 0 ustar 00root root 0000000 0000000 # Jasmine Npm 2.99 Release Notes
## Summary
This release is part of the upgrade path to Jasmine 3.0. Please see the [release notes for Jasmine-Core](https://github.com/jasmine/jasmine/blob/master/release_notes/2.99.md)
## Changes
* Report deprecation warnings in CI output
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/3.0.md 0000664 0000000 0000000 00000002104 14327321345 0017411 0 ustar 00root root 0000000 0000000 # Jasmine NPM 3.0 Release Notes
## Summary
Jasmine 3.0 is a major release of Jasmine, and as such includes some breaking changes in addition to various new features.
Please see the [release notes for Jasmine-Core](https://github.com/jasmine/jasmine/blob/master/release_notes/3.0.md)
There is also a 2.99 release of Jasmine that will present deprecation warnings for suites that will encounter different behavior in 3.0.
## Changes
* Support stopping jasmine execution on first spec failure via config object or with `--fail-fast` command line arg
- Fixes [#16](https://github.com/jasmine/jasmine-npm/issues/16)
* Add ability to pass `--reporter` on the command line
- Fixes [jasmine/jasmine#1027](https://github.com/jasmine/jasmine/issues/1027)
* Print full details for suite failures
* Report how to re-run Jasmine with the current seed
* Run specs in random order by default
* Treat suites with focused specs as failures
* Removed deprecated completion callback from console reporter
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/3.1.0.md 0000664 0000000 0000000 00000001030 14327321345 0017545 0 ustar 00root root 0000000 0000000 # Jasmine NPM 3.1 Release Notes
## Summary
This release updates the jasmine-core dependency to 3.1.0. See the
[jasmine-core release notes](https://github.com/pivotal/jasmine/blob/master/release_notes/3.1.0.md)
for more information.
## Changes
* Tell Jasmine-core not to handle load errors itself
- Fixes [jasmine/jasmine#1519](https://github.com/jasmine/jasmine/issues/1519)
* better error reporting when an invalid --reporter is specified
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/3.10.0.md 0000664 0000000 0000000 00000003211 14327321345 0017630 0 ustar 00root root 0000000 0000000 # Jasmine NPM 3.10 Release Notes
This release updates the jasmine-core dependency to 3.10.0. See the
[jasmine-core release notes](https://github.com/pivotal/jasmine/blob/main/release_notes/3.10.0.md)
for more information.
## New features and bugfixes
* Support for executing the suite multiple times
* See the jasmine-core release notes for details
* Display the top suite name as "top suite", not "undefined" when reporting
suite-level failures
* Fixed reporting of load-time errors from modules imported by specs
* Made the promise returned from `Jasmine#execute` usable
* Added an exitOnCompletion property to directly control whether Jasmine
should make the Node process exit. Previously this could only be done by
calling `Jasmine#onComplete`.
* The promise returned from `Jasmine#execute` is resolved to the overall
status.
* Improved interface for programmatically adding files
* Added Jasmine#addHelperFile
* Added more clearly named synonyms for Jasmine#addSpecFiles and
Jasmine#addHelperFiles, and marked the old ones deprecated
## Documentation improvements
* Added jsdoc for `Jasmine#env`
## Internal updates
* Pass stopOnSpecFailure and stopSpecOnExpectationFailure options to core,
not the deprecated failFast and oneFailurePerSpec options
* Replaced var with const and let
* Test suite improvements
## Supported environments
The jasmine NPM package has been tested on Node 12, 14, and 16. See the
[jasmine-core release notes](https://github.com/jasmine/jasmine/blob/main/release_notes/3.10.0.md)
for supported browsers.
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/3.2.0.md 0000664 0000000 0000000 00000001712 14327321345 0017555 0 ustar 00root root 0000000 0000000 # Jasmine NPM 3.2 Release Notes
## Summary
This release updates the jasmine-core dependency to 3.2.0. See the
[jasmine-core release notes](https://github.com/pivotal/jasmine/blob/master/release_notes/3.2.0.md)
for more information.
## Changes
* Unknown command line options produce exit code 1
- Merges [#138](https://github.com/jasmine/jasmine-npm/issues/138) from @enelson
- Fixes [#137](https://github.com/jasmine/jasmine-npm/issues/137)
* Add option "require(s)" to command line and config file
- Merges [#136](https://github.com/jasmine/jasmine-npm/issues/136) from @liuxh0
- Fixes [#135](https://github.com/jasmine/jasmine-npm/issues/135)
* Add --color option
- Merges [#132](https://github.com/jasmine/jasmine-npm/issues/132) from @susisu
* fix --filter in README
- Merges [#131](https://github.com/jasmine/jasmine-npm/issues/131) from @cancerberoSgx
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/3.3.0.md 0000664 0000000 0000000 00000001344 14327321345 0017557 0 ustar 00root root 0000000 0000000 # Jasmine NPM 3.3 Release Notes
## Summary
This release updates the jasmine-core dependency to 3.3.0. See the
[jasmine-core release notes](https://github.com/pivotal/jasmine/blob/master/release_notes/3.3.0.md)
for more information.
## Changes
* Wait until streams are completed before exiting to prevent output cropping when jasmine is called form another process
- Merges [#141](https://github.com/jasmine/jasmine-npm/issues/141) from @jkytomak
* Allow excluding spec files and helper files
- Merges [#140](https://github.com/jasmine/jasmine-npm/issues/140) from @liuxh0
- Fixes [#128](https://github.com/jasmine/jasmine-npm/issues/128)
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/3.3.1.md 0000664 0000000 0000000 00000001116 14327321345 0017555 0 ustar 00root root 0000000 0000000 # Jasmine NPM 3.3.1 Release Notes
## Summary
This is a bug fix release to clean up the deprecation warning introduced in 3.3.0
## Changes
* Add `null` encoding when writing to streams on close
- Fixes [jasmine/jasmine#1622](https://github.com/jasmine/jasmine/issues/1622)
* Changes to avoid config deprecation warnings (from jasmine-core).
- Merges [#147](https://github.com/jasmine/jasmine-npm/issues/147) from @claudiosdc
- Fixes [#145](https://github.com/jasmine/jasmine-npm/issues/145)
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/3.4.0.md 0000664 0000000 0000000 00000001415 14327321345 0017557 0 ustar 00root root 0000000 0000000 # Jasmine NPM 3.4 Release Notes
## Summary
This release updates the jasmine-core dependency to 3.4.0. See the
[jasmine-core release notes](https://github.com/pivotal/jasmine/blob/master/release_notes/3.4.0.md)
for more information.
## Changes
* Use `removeListener` instead of `off` since it always exists
* moved exit listener add and removal to completion reporter
- Merges [#149](https://github.com/jasmine/jasmine-npm/issues/149) from @battk
- Fixes [#134](https://github.com/jasmine/jasmine-npm/issues/134)
- Fixes [#125](https://github.com/jasmine/jasmine-npm/issues/125)
* Update README.md
- Merges [#146](https://github.com/jasmine/jasmine-npm/issues/146) from @strama4
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/3.5.0.md 0000664 0000000 0000000 00000000627 14327321345 0017564 0 ustar 00root root 0000000 0000000 # Jasmine NPM 3.5 Release Notes
## Summary
This release updates the jasmine-core dependency to 3.5.0. See the
[jasmine-core release notes](https://github.com/pivotal/jasmine/blob/master/release_notes/3.5.0.md)
for more information.
## Changes
* Use the total time from Jasmine-Core instead of calculating ourself
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/3.6.0.md 0000664 0000000 0000000 00000001653 14327321345 0017565 0 ustar 00root root 0000000 0000000 # Jasmine NPM 3.6 Release Notes
## Summary
This release updates the jasmine-core dependency to 3.6.0. See the
[jasmine-core release notes](https://github.com/pivotal/jasmine/blob/main/release_notes/3.6.0.md)
for more information.
## Changes
* Removed unnecessary check for passedExpectations truthiness
* Support 'failSpecWithNoExpectations' config option and include a message in the default ConsoleReporter when a spec contains no expectations
* Merges [#157](https://github.com/jasmine/jasmine-npm/pull/157) from @coyoteecd
* Fixes [#156](https://github.com/jasmine/jasmine-npm/issues/156)
* Don't parse argv after --
* Merges [#155](https://github.com/jasmine/jasmine-npm/pull/155) from @tharvik
* Added support for running specs in parallel
* Merges [#153](https://github.com/jasmine/jasmine-npm/pull/153) from @wood1986
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/3.6.1.md 0000664 0000000 0000000 00000000442 14327321345 0017561 0 ustar 00root root 0000000 0000000 # Jasmine NPM 3.6.1 Release Notes
## Summary
This release fixes a bug in the multi-threading logic to ensure spec files are only loaded once
## Changes
* Only load spec files once
* Fixes #161
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/3.6.2.md 0000664 0000000 0000000 00000002077 14327321345 0017570 0 ustar 00root root 0000000 0000000 # Jasmine NPM 3.6.2 Release Notes
# Summary
This release fixes an issue with load order of helper files introduced by switching globbing libraries
# Changes
Added support for ES modules
* Fixes [#150](https://github.com/jasmine/jasmine-npm/issues/150).
* Specs and helpers with names ending in .mjs are loaded as ES modules
(`import("foo.mjs")`).
* All other specs and helpers are loaded as CommonJS modules, as before
(`require("foo.js")`).
* If using ES modules with Node 10 or 11, run
`node --experimental-modules /path/to/jasmine` instead of `jasmine`.
Switch back to just plain `glob` for smaller dependency list
* Fixes [#162](https://github.com/jasmine/jasmine-npm/issues/162)
Remove code related to multiple workers as it never worked in the first place
* See [#153](https://github.com/jasmine/jasmine-npm/issues/153)
* Fixes [#163](https://github.com/jasmine/jasmine-npm/issues/163)
* Fixes [#165](https://github.com/jasmine/jasmine-npm/issues/165)
* See also discussion in [#162](https://github.com/jasmine/jasmine-npm/issues/162)
jasmine-npm-4.5.0/release_notes/3.6.3.md 0000664 0000000 0000000 00000001362 14327321345 0017565 0 ustar 00root root 0000000 0000000 # Jasmine NPM 3.6.3 Release Notes
## Summary
This release fixes several bugs related to module loading.
## Changes
Fixed ES module loading on Windows
* Fixes [#169](https://github.com/jasmine/jasmine-npm/issues/169)
Include the filename in the error when an ES module has syntax errors
* Fixes [#168](https://github.com/jasmine/jasmine-npm/issues/168)
Exit nonzero when a spec fails to load
* Fixes [#167](https://github.com/jasmine/jasmine-npm/issues/167)
Clarify which Node versions are supported
* 10.x, 12.x, and 14.x are supported.
* Odd-numbered major versions are very likely to work, but they aren't supported or tested against.
* See the `engines` field in `package.json` in this and future releases for the current list.
jasmine-npm-4.5.0/release_notes/3.6.4.md 0000664 0000000 0000000 00000001050 14327321345 0017560 0 ustar 00root root 0000000 0000000 # Jasmine NPM 3.6.4 Release Notes
## Summary
This is a bugfix release that removes the `engines` specification.
## Changes
* Removed `engines` field from package.json
The engines field was added in 3.6.3 in an attempt to better document the set
of Node versions that Jasmine supports, but it's caused more problems than it
solves. In particular, Yarn users receive an error rather than a warning when
using a version of Node that works but isn't supported.
See for a list of supported Node
versions.
jasmine-npm-4.5.0/release_notes/3.7.0.md 0000664 0000000 0000000 00000000351 14327321345 0017560 0 ustar 00root root 0000000 0000000 # Jasmine NPM 3.7 Release Notes
## Summary
This release updates the jasmine-core dependency to 3.7.0. See the
[jasmine-core release notes](https://github.com/pivotal/jasmine/blob/main/release_notes/3.7.0.md)
for more information.
jasmine-npm-4.5.0/release_notes/3.8.0.md 0000664 0000000 0000000 00000003333 14327321345 0017564 0 ustar 00root root 0000000 0000000 # Jasmine NPM 3.8 Release Notes
## Summary
This release updates the jasmine-core dependency to 3.8.0. See the
[jasmine-core release notes](https://github.com/pivotal/jasmine/blob/main/release_notes/3.8.0.md)
for more information.
# New features and bug fixes
* Opt-in support for ES modules with .js extension and package type `module`
* All files are loaded using `import` if `"jsLoader": "import"` is set in
the config file.
* Only supported on Node >= 12.17.0. Older versions have missing or broken
support for importing .js files.
* Fixes [#170](https://github.com/jasmine/jasmine-npm/issues/170)
* Allow the random seed reproduction command to be overridden
* Needed by jasmine-browser-runner, which uses the ConsoleReporter but needs
to tell the user to run a different command.
# Documentation updates
* Created an initial set of [API reference documentation](https://jasmine.github.io/api/npm/3.8/index)
# Internal notes
* Specify files to include in the NPM package rather than files to exclude
* CI matrix updates
* Added Node 16.
* Added Node 12.0, 12.16, and 12.17 to ensure coverage of versions that do
and don't have good support for importing .js files.
* Removed Windows. We'll manually run the tests on Windows before each
release, but we no longer have reliable access to a free Windows CI
service.
* Migrated from Travis to Circle CI
## Supported environments
The jasmine NPM package has been tested on Node 12, 14, 16, and 18. See the
[jasmine-core release notes](https://github.com/jasmine/jasmine/blob/main/release_notes/3.8.0.md)
for supported browsers.
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/3.9.0.md 0000664 0000000 0000000 00000001605 14327321345 0017565 0 ustar 00root root 0000000 0000000 # Jasmine NPM Release Notes
This release updates the jasmine-core dependency to 3.9.0. See the
[jasmine-core release notes](https://github.com/pivotal/jasmine/blob/main/release_notes/3.9.0.md)
for more information.
## New features and bug fixes
* Allow arbitrary env configuration to be specified via the `env` config field
This allows us to automatically support new env config properties in the
future without any code changes.
* Default to including .mjs as well as .js in newly generated config files
* Fixes #176
# Documentation improvements
* Added jsdoc for Jasmine.prototype.configureDefaultReporter
* Fixed copy-paste error in docs
* Merges [#183](https://github.com/jasmine/jasmine-npm/pull/183) from @UziTech
## Internal notes
* Removed vestigal code for old `timer` reporter option
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/3.99.0.md 0000664 0000000 0000000 00000000526 14327321345 0017657 0 ustar 00root root 0000000 0000000 # Jasmine NPM 3.99.0 Release Notes
This release adds deprecation warnings for breaking changes that will be
introduced in Jasmine 4.0. Please see the
[migration guide](https://jasmine.github.io/tutorials/upgrading_to_Jasmine_4.0)
for more information.
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/4.0.0.md 0000664 0000000 0000000 00000010526 14327321345 0017557 0 ustar 00root root 0000000 0000000 # Jasmine NPM 4.0.0 Release Notes
## Summary
This is a major release. In addition to new features and bug fixes it contains
a variety of breaking changes that are intended to improve ES module support,
improve awkward or outdated interfaces, and make Jasmine easier to maintain
and contribute to. If you're upgrading from Jasmine 3.x, we recommend installing
3.99 and fixing any deprecation warnings that it emits before updating to 4.0.
See the [migration guide](https://jasmine.github.io/tutorials/upgrading_to_Jasmine_4.0)
for more information. Be sure to read the release notes for `jasmine-core` 4.0.0
as well.
## Highlights
* The `jasmine-core` dependency has been updated to 4.0.0
* ES module support is enabled by default.
* Node 10 and 12.0-12.16 are no longer supported.
## Breaking changes
* Node versions older than 12.17 are no longer supported because they have
insufficient support for interop between ES modules and CommonJS modules.
* Beginning with this release, everything not documented in the
[API reference](https://jasmine.github.io/api/npm/4.0/Jasmine) is considered
a private API.
* ES module support is enabled by default, but can still be disabled by
adding `jsLoader: "require"` to the configuration. `jsLoader: "import"` is
now a no-op.
This change breaks loading of files with extensions that aren't supported by
dynamic `import()`, such as `.jsx`, although that has been subsequently fixed
in 4.0.1. If you have specs or source files with such extensions, please
update to at least 4.0.1. Alternately you can either rename the files to
`.js` or add `jsLoader: "require"` to your Jasmine config file.
* Config files can be ES modules. This is a breaking change because it requires
`Jasmine#loadConfigFile` to be async.
* The `--fail-fast` CLI flag now causes Jasmine to stop spec execution on the
first expectation failure as well as stopping suite execution on the first
spec failure.
* The ambiguously named `--stop-on-failure` CLI flag is no longer supported.
* Failure to load or instantiate a reporter is a fatal error, not just a warning.
* Relative reporter paths are resolved based on the working directory rather
than the location of the module inside Jasmine that calls `require()`.
* The `jasmine` command now uses distinct exit codes for various types of non-success:
* 1 for anything unexpected, i.e. Jasmine didn't run to completion
* 2 for incomplete (focused specs/suites but no failures)
* 3 for failed (spec/suite failures)
* Other nonzero exit codes may be used for other purposes. Code that checks
the exit code of the `jasmine` command should not treat any value other than
0 as success.
* Fixes [#154](https://github.com/jasmine/jasmine-npm/issues/154).
* `Jasmine#onComplete` is no longer supported. To run code after execution
finishes, set the Jasmine instance's `exitOnCompletion` to false and use the
promise returned by `Jasmine#execute`. See the
[API reference for `execute`](https://jasmine.github.io/api/npm/4.0/Jasmine.html#execute)
for more information.
## New features and bugfixes
* Files listed in the `requires` config property can be ES modules
* Reporters specified with `--reporter=` can be ES modules.
* Allow use without creating globals.
* See .
* Fixes [jasmine/jasmine#1235](https://github.com/jasmine/jasmine/issues/1235).
* Autodiscover spec/support/jasmine.js as well as spec/support/jasmine.json.
* Moved `stopSpecOnExpectationFailure` and `random` to `env` in the sample
config generated by `jasmine init`.
* Top suite failures are included in the failure count displayed by the default
`ConsoleReporter`.
* Added support for the debug logging feature introduced in `jasmine-core` 4.0.0.
* Fixed handling of module paths containing `..` on OS X.
## Internal improvements
* Use the promise returned from `Env#execute` to determine when suite execution
is finished and obtain the overall result.
* Removed unnecessary code to filter Jasmine's frames from stack traces. The same
filtering has been done in jasmine-core since 3.0.
* Inlined loadConfig.js back into command.js to resolve naming conflicts.
## Supported environments
The jasmine NPM package has been tested on Node 12.17-12.22, 14, and 16.
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/4.0.1.md 0000664 0000000 0000000 00000000631 14327321345 0017554 0 ustar 00root root 0000000 0000000 # Jasmine NPM 4.0.1 Release Notes
## Summary
This release fixes loading of files with nonstandard extensions (e.g. .jsx,
.coffee) in the default configuration by falling back to `require()` when
`import()` fails because of an unsupported file extension. See
[#188](https://github.com/jasmine/jasmine-npm/issues/188).
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/4.0.2.md 0000664 0000000 0000000 00000000774 14327321345 0017565 0 ustar 00root root 0000000 0000000 # Jasmine NPM 4.0.2 Release Notes
This release fixes two bugs related to reporter loading.
* Fixed loading of reporters in NPM packages (i.e. not a file path) in the
default configuration
* Fixes [#189](https://github.com/jasmine/jasmine-npm/issues/189)
* The `jsLoader` configuration setting is followed when loading reporters
* Merges [#190](https://github.com/jasmine/jasmine-npm/pull/190) from @ffortier
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/4.1.0.md 0000664 0000000 0000000 00000000467 14327321345 0017563 0 ustar 00root root 0000000 0000000 # Jasmine NPM 4.1.0 Release Notes
This release updates the jasmine-core dependency to 4.1.0. See the
[jasmine-core release notes](https://github.com/jasmine/jasmine/blob/main/release_notes/4.1.0.md)
for more information.
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/4.2.0.md 0000664 0000000 0000000 00000000640 14327321345 0017555 0 ustar 00root root 0000000 0000000 # Jasmine NPM 4.2.0 Release Notes
This release updates the jasmine-core dependency to 4.2.0. See the
[jasmine-core release notes](https://github.com/jasmine/jasmine/blob/main/release_notes/4.2.0.md)
for more information.
## Supported environments
The jasmine NPM package has been tested on Node 12.17-12.22, 14, 16, and 18.
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/4.2.1.md 0000664 0000000 0000000 00000000653 14327321345 0017562 0 ustar 00root root 0000000 0000000 # Jasmine NPM 4.2.1 Release Notes
## Bug Fixes
* Fixed the `--helper` option
* Merges [#198](https://github.com/jasmine/jasmine-npm/pull/198) from @lucaswerkmeister
* Fixes [#197](https://github.com/jasmine/jasmine-npm/issues/197)
## Supported environments
The jasmine package has been tested on Node 12.17-12.22, 14, 16, and 18.
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/4.3.0.md 0000664 0000000 0000000 00000001656 14327321345 0017566 0 ustar 00root root 0000000 0000000 # Jasmine NPM 4.3.0 Release Notes
This release updates the jasmine-core dependency to 4.3.0. See the
[jasmine-core release notes](https://github.com/jasmine/jasmine/blob/main/release_notes/4.3.0.md)
for more information.
# New features
* Added a config option to disable listing pending specs when there are failures
* This can make failure output easier to read when there are also a number of
pending specs. To use this feature, add `alwaysListPendingSpecs: false` to
the config file or call `.alwaysListPendingSpecs(false)` on the `Jasmine`
instance.
## Documentation updates
* Added a contributing guide
* Copied CODE_OF_CONDUCT from core repo
## Internal improvements
* Converted `Jasmine` and `Loader` to ES6 classes
## Supported environments
The jasmine NPM package has been tested on Node 12.17-12.22, 14, 16, and 18.
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/4.4.0.md 0000664 0000000 0000000 00000000640 14327321345 0017557 0 ustar 00root root 0000000 0000000 # Jasmine NPM 4.4.0 Release Notes
This release updates the jasmine-core dependency to 4.4.0. See the
[jasmine-core release notes](https://github.com/jasmine/jasmine/blob/main/release_notes/4.4.0.md)
for more information.
## Supported environments
The jasmine NPM package has been tested on Node 12.17-12.22, 14, 16, and 18.
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/release_notes/4.5.0.md 0000664 0000000 0000000 00000002121 14327321345 0017554 0 ustar 00root root 0000000 0000000 # Jasmine NPM 4.5.0 Release Notes
This release updates the jasmine-core dependency to 4.5.0. See the
[jasmine-core release notes](https://github.com/jasmine/jasmine/blob/main/release_notes/4.5.0.md)
for more information.
## New Features
* Warn when backslashes are used in paths/globs on Windows
* Backslashes behave inconsistently between OSes in the version of glob
that Jasmine currently uses. The next major version of glob will treat
them as escape sequences rather than path separators on all OSes.
* Allow instantiated reporters to be provided in the configuration
* This supports more complex scenarios than the --reporter= CLI flag
(multiple reporters, reporters that need configuration, reporters
that aren't default exports, etc) without requiring a switch to programmatic
usage.
## Documentation Improvements
* Fixed default value of Configuration#alwaysListPendingSpecs
## Supported environments
The jasmine NPM package has been tested on Node 12.17-12.22, 14, 16, and 18.
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
jasmine-npm-4.5.0/spec/ 0000775 0000000 0000000 00000000000 14327321345 0014674 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/command_spec.js 0000664 0000000 0000000 00000042704 14327321345 0017671 0 ustar 00root root 0000000 0000000 const fs = require('fs');
const path = require('path');
const Command = require('../lib/command');
const Loader = require("../lib/loader");
const projectBaseDir = 'spec/fixtures/sample_empty_project/';
const spec = path.join(projectBaseDir, 'spec');
function deleteDirectory(dir) {
if (fs.existsSync(dir)) {
const dirFiles = fs.readdirSync(dir);
dirFiles.forEach(function(file) {
const fullPath = path.join(dir, file);
if (fs.statSync(fullPath).isDirectory()) {
deleteDirectory(fullPath);
}
else if (fs.statSync(fullPath).isFile()) {
fs.unlinkSync(fullPath);
}
});
fs.rmdirSync(dir);
}
}
async function withValueForIsTTY(value, func) {
const wasTTY = process.stdout.isTTY;
try {
process.stdout.isTTY = value;
await func();
} finally {
process.stdout.isTTY = wasTTY;
}
}
describe('command', function() {
beforeEach(function() {
const examplesDir = path.resolve(path.join(__dirname, 'fixtures', 'example'));
fs.mkdirSync(projectBaseDir);
this.out = (function() {
let output = "";
return {
print: function(str) {
output += str;
},
getOutput: function() {
return output;
}
};
}());
this.command = new Command(projectBaseDir, examplesDir, {
print: this.out.print,
platform: () => 'Oberon'
});
this.fakeJasmine = jasmine.createSpyObj('jasmine', ['loadConfigFile', 'addMatchingHelperFiles', 'addRequires', 'showColors', 'execute',
'randomizeTests', 'seed', 'coreVersion', 'clearReporters', 'addReporter']);
this.fakeJasmine.loader = new Loader();
this.fakeJasmine.env = jasmine.createSpyObj('env', ['configure']);
this.fakeJasmine.execute.and.returnValue(Promise.resolve());
});
afterEach(function() {
deleteDirectory(projectBaseDir);
});
describe('passing in environment variables', function() {
beforeEach(function () {
this.command.run(this.fakeJasmine, ['node', 'bin/jasmine.js', 'TESTKEY=TESTVALUE']);
});
afterEach(function() {
delete process.env.TESTKEY;
});
it('should run with those environment variables', function() {
expect(process.env.TESTKEY).toBe('TESTVALUE');
});
});
describe('init', function() {
beforeEach(function() {
this.command.run(this.fakeJasmine, ['node', 'bin/jasmine.js', 'init']);
});
it('creates setup folders and files for specs', function() {
expect(fs.existsSync(path.join(spec, 'support/', 'jasmine.json'))).toBe(true);
});
it('writes default settings to jasmine.json', function() {
const realJson = fs.readFileSync(path.join(spec, 'support/', 'jasmine.json'), 'utf-8');
const fixtureJson = fs.readFileSync(path.join(__dirname, '../', 'lib/', 'examples/', 'jasmine.json'), 'utf-8');
expect(realJson).toEqual(fixtureJson);
});
});
describe('version', function() {
beforeEach(function() {
this.fakeJasmine.coreVersion.and.returnValue('fake core version');
this.command.run(this.fakeJasmine, ['node', 'bin/jasmine.js', 'version']);
});
it('displays the version of jasmine', function() {
const packageVersion = require('../package.json').version;
expect(this.out.getOutput()).toContain('jasmine v' + packageVersion);
});
it('displays the version of jasmine-core', function() {
expect(this.out.getOutput()).toContain('jasmine-core vfake core version');
});
});
describe('-v', function() {
beforeEach(function() {
this.fakeJasmine.coreVersion.and.returnValue('fake core version');
this.command.run(this.fakeJasmine, ['node', 'bin/jasmine.js', '-v']);
});
it('displays the version of jasmine', function() {
const packageVersion = require('../package.json').version;
expect(this.out.getOutput()).toContain('jasmine v' + packageVersion);
});
it('displays the version of jasmine-core', function() {
expect(this.out.getOutput()).toContain('jasmine-core vfake core version');
});
});
describe('passing unknown options', function() {
beforeEach(function() {
this.exitCode = process.exitCode;
});
afterEach(function() {
process.exitCode = this.exitCode;
});
it('displays unknown options and usage', function() {
this.command.run(this.fakeJasmine, ['node', 'bin/jasmine.js', '--some-option', '--no-color', '--another-option']);
expect(this.out.getOutput()).toContain('Unknown options: --some-option, --another-option');
expect(this.out.getOutput()).toContain('Usage');
expect(process.exitCode).toBe(1);
});
});
describe('--', function() {
it('skips anything after it', async function() {
await withValueForIsTTY(true, async function () {
await this.command.run(this.fakeJasmine, ['node', 'bin/jasmine.js', '--', '--no-color']);
expect(this.out.getOutput()).toBe('');
expect(this.fakeJasmine.showColors).toHaveBeenCalledWith(true);
}.bind(this));
});
});
describe('examples', function() {
beforeEach(function() {
this.command.run(this.fakeJasmine, ['node', 'bin/jasmine.js', 'examples']);
});
it('should create init files if they do not exist', function() {
expect(fs.existsSync(path.join(spec, 'jasmine_examples'))).toBe(true);
expect(fs.existsSync(path.join(projectBaseDir, 'lib', 'jasmine_examples'))).toBe(true);
expect(fs.existsSync(path.join(spec, 'helpers', 'jasmine_examples'))).toBe(true);
});
it('should copy files into the appropriate folder', function() {
expect(fs.existsSync(path.join(projectBaseDir, 'lib', 'jasmine_examples', 'Foo.js'))).toBe(true);
expect(fs.existsSync(path.join(projectBaseDir, 'lib', 'jasmine_examples', 'Bar.js'))).toBe(true);
expect(fs.existsSync(path.join(spec, 'jasmine_examples', 'FooSpec.js'))).toBe(true);
expect(fs.existsSync(path.join(spec, 'helpers', 'jasmine_examples', 'SpecHelper.js'))).toBe(true);
});
});
describe('running specs', function() {
beforeEach(function() {
this.originalConfigPath = process.env.JASMINE_CONFIG_PATH;
});
afterEach(function() {
if (this.originalConfigPath) {
process.env.JASMINE_CONFIG_PATH = this.originalConfigPath;
} else {
delete process.env.JASMINE_CONFIG_PATH;
}
});
it('should load the default config file', async function() {
await this.command.run(this.fakeJasmine, ['node', 'bin/jasmine.js']);
expect(this.fakeJasmine.loadConfigFile).toHaveBeenCalledWith(undefined);
});
it('should load a custom config file specified by env variable', async function() {
await this.command.run(this.fakeJasmine, ['node', 'bin/jasmine.js', 'JASMINE_CONFIG_PATH=somewhere.json']);
expect(this.fakeJasmine.loadConfigFile).toHaveBeenCalledWith('somewhere.json');
});
it('should load a custom config file specified by option', async function() {
await this.command.run(this.fakeJasmine, ['node', 'bin/jasmine.js', '--config=somewhere.json']);
expect(this.fakeJasmine.loadConfigFile).toHaveBeenCalledWith('somewhere.json');
});
it('should show colors by default if stdout is a TTY', async function() {
await withValueForIsTTY(true, async function () {
await this.command.run(this.fakeJasmine, ['node', 'bin/jasmine.js']);
expect(this.fakeJasmine.showColors).toHaveBeenCalledWith(true);
}.bind(this));
});
it('should not show colors by default if stdout is not a TTY', async function() {
await withValueForIsTTY(undefined, async function () {
await this.command.run(this.fakeJasmine, ['node', 'bin/jasmine.js']);
expect(this.fakeJasmine.showColors).toHaveBeenCalledWith(false);
}.bind(this));
});
it('should allow colors to be turned off', async function() {
await this.command.run(this.fakeJasmine, ['node', 'bin/jasmine.js', '--no-color']);
expect(this.fakeJasmine.showColors).toHaveBeenCalledWith(false);
});
it('should be able to force colors to be turned on', async function() {
await withValueForIsTTY(undefined, async function () {
await this.command.run(this.fakeJasmine, ['node', 'bin/jasmine.js', '--color']);
expect(this.fakeJasmine.showColors).toHaveBeenCalledWith(true);
}.bind(this));
});
it('should execute the jasmine suite', async function() {
await this.command.run(this.fakeJasmine, ['node', 'bin/jasmine.js']);
expect(this.fakeJasmine.execute).toHaveBeenCalled();
});
it('should be able to run only specified specs', async function() {
await this.command.run(this.fakeJasmine, ['spec/some/fileSpec.js', 'SOME_ENV=SOME_VALUE', '--no-color']);
expect(this.fakeJasmine.execute).toHaveBeenCalledWith(['spec/some/fileSpec.js'], undefined);
});
it('should be able filter by spec name', async function() {
await this.command.run(this.fakeJasmine, ['--filter=interesting spec']);
expect(this.fakeJasmine.execute).toHaveBeenCalledWith(jasmine.any(Array), 'interesting spec');
});
it('should be able to add one helper pattern', async function() {
await this.command.run(this.fakeJasmine, ['--helper=helpers/**/*.js']);
expect(this.fakeJasmine.addMatchingHelperFiles).toHaveBeenCalledWith(['helpers/**/*.js']);
});
it('should be able to add many helper patterns', async function() {
await this.command.run(this.fakeJasmine, ['--helper=helpers/**/*.js', '--helper=other.js']);
expect(this.fakeJasmine.addMatchingHelperFiles).toHaveBeenCalledWith(['helpers/**/*.js', 'other.js']);
});
it('should not modify helper patterns if no argument given', async function() {
await this.command.run(this.fakeJasmine, []);
expect(this.fakeJasmine.addMatchingHelperFiles).not.toHaveBeenCalled();
});
it('should be able to add one require', async function() {
await this.command.run(this.fakeJasmine, ['--require=ts-node/require']);
expect(this.fakeJasmine.addRequires).toHaveBeenCalledWith(['ts-node/require']);
});
it('should be able to add multiple requires', async function() {
await this.command.run(this.fakeJasmine, ['--require=ts-node/require', '--require=@babel/register']);
expect(this.fakeJasmine.addRequires).toHaveBeenCalledWith(['ts-node/require', '@babel/register']);
});
it('can specify a reporter', async function() {
const reporterPath = path.resolve(path.join(__dirname, 'fixtures', 'customReporter.js'));
const Reporter = require(reporterPath);
await this.command.run(this.fakeJasmine, ['--reporter=' + reporterPath]);
expect(this.fakeJasmine.clearReporters).toHaveBeenCalled();
expect(this.fakeJasmine.addReporter).toHaveBeenCalledWith(jasmine.any(Reporter));
});
it('uses the provided loader to load reporters', async function() {
const reporterPath = path.resolve(path.join(__dirname, 'fixtures', 'customReporter.js'));
spyOn(this.fakeJasmine.loader, 'load').and.callThrough();
await this.command.run(this.fakeJasmine, ['--reporter=' + reporterPath]);
expect(this.fakeJasmine.loader.load).toHaveBeenCalledWith(reporterPath);
});
it('can specify a reporter that is an ES module', async function() {
await this.command.run(this.fakeJasmine, ['--reporter=./spec/fixtures/customReporter.mjs']);
expect(this.fakeJasmine.clearReporters).toHaveBeenCalled();
expect(this.fakeJasmine.addReporter.calls.argsFor(0)[0].isCustomReporterDotMjs).toBe(true);
});
describe('When the reporter path is relative', function() {
beforeEach(function() {
this.originalWd = process.cwd();
});
afterEach(function() {
process.chdir(this.originalWd);
});
it('evaluates the path based on the cwd', async function() {
const Reporter = require('./fixtures/customReporter.js');
process.chdir('spec/fixtures');
await this.command.run(this.fakeJasmine, ['--reporter=./customReporter.js']);
expect(this.fakeJasmine.clearReporters).toHaveBeenCalled();
expect(this.fakeJasmine.addReporter).toHaveBeenCalledWith(jasmine.any(Reporter));
this.fakeJasmine.clearReporters.calls.reset();
this.fakeJasmine.addReporter.calls.reset();
process.chdir('example');
await this.command.run(this.fakeJasmine, ['--reporter=../customReporter.js']);
expect(this.fakeJasmine.clearReporters).toHaveBeenCalled();
expect(this.fakeJasmine.addReporter).toHaveBeenCalledWith(jasmine.any(Reporter));
});
});
it('throws with context if the file does not export a reporter', async function() {
const reporterPath = path.resolve(path.join(__dirname, 'fixtures', 'badReporter.js'));
await expectAsync(
this.command.run(this.fakeJasmine, ['--reporter=' + reporterPath])
).toBeRejectedWithError(new RegExp(
'Failed to instantiate reporter from ' +
escapeStringForRegexp(reporterPath) + '\nUnderlying error: .' +
'*Reporter is not a constructor'
));
expect(this.fakeJasmine.clearReporters).not.toHaveBeenCalled();
expect(this.fakeJasmine.addReporter).not.toHaveBeenCalled();
});
it('throws with context if the reporter file does not exist', async function() {
const reporterPath = path.resolve(path.join(__dirname, 'fixtures', 'missingReporter.js'));
await expectAsync(
this.command.run(this.fakeJasmine, ['--reporter=' + reporterPath])
).toBeRejectedWithError(new RegExp(
'Failed to load reporter module ' +
escapeStringForRegexp(reporterPath) + '\nUnderlying error: ' +
'.*Cannot find module'
));
expect(this.fakeJasmine.clearReporters).not.toHaveBeenCalled();
expect(this.fakeJasmine.addReporter).not.toHaveBeenCalled();
});
it('should not configure fail fast by default', async function() {
await this.command.run(this.fakeJasmine, []);
expect(this.fakeJasmine.env.configure).not.toHaveBeenCalledWith(jasmine.objectContaining({
stopOnSpecFailure: jasmine.anything()
}));
expect(this.fakeJasmine.env.configure).not.toHaveBeenCalledWith(jasmine.objectContaining({
stopSpecOnExpectationFailure: jasmine.anything()
}));
});
it('should be able to turn on fail fast', async function() {
await this.command.run(this.fakeJasmine, ['--fail-fast']);
expect(this.fakeJasmine.env.configure).toHaveBeenCalledWith({
stopOnSpecFailure: true,
stopSpecOnExpectationFailure: true
});
});
it('uses jasmine-core defaults if random is unspecified', async function() {
await this.command.run(this.fakeJasmine, []);
expect(this.fakeJasmine.randomizeTests).not.toHaveBeenCalled();
});
it('should be able to turn on random tests', async function() {
await this.command.run(this.fakeJasmine, ['--random=true']);
expect(this.fakeJasmine.randomizeTests).toHaveBeenCalledWith(true);
});
it('should be able to turn off random tests', async function() {
await this.command.run(this.fakeJasmine, ['--random=false']);
expect(this.fakeJasmine.randomizeTests).toHaveBeenCalledWith(false);
});
it('should not configure seed by default', async function() {
await this.command.run(this.fakeJasmine, []);
expect(this.fakeJasmine.seed).not.toHaveBeenCalled();
});
it('should be able to set a seed', async function() {
await this.command.run(this.fakeJasmine, ['--seed=12345']);
expect(this.fakeJasmine.seed).toHaveBeenCalledWith('12345');
});
});
describe('Path handling', function() {
describe('On Windows', function () {
beforeEach(function() {
this.deps = {
print: this.out.print,
platform: () => 'win32'
};
});
it('replaces backslashes in the project base dir with slashes', function() {
const subject = new Command('foo\\bar', '', this.deps);
expect(subject.projectBaseDir).toEqual('foo/bar');
expect(subject.specDir).toEqual('foo/bar/spec');
});
it('replaces backslashes in spec file paths from the command line', async function() {
const subject = new Command('arbitrary', '', this.deps);
await subject.run(this.fakeJasmine, ['somedir\\somespec.js']);
expect(this.fakeJasmine.execute).toHaveBeenCalledWith(['somedir/somespec.js'], undefined);
});
});
describe('On non-Windows systems', function () {
beforeEach(function() {
this.deps = {
print: this.out.print,
platform: () => 'BeOS'
};
});
it('does not replace backslashes in the project base dir', function() {
const subject = new Command('foo\\bar', '', this.deps);
expect(subject.projectBaseDir).toEqual('foo\\bar');
expect(subject.specDir).toEqual('foo\\bar/spec');
});
it('does not replace backslashes in spec file paths from the command line', async function() {
const subject = new Command('arbitrary', '', this.deps);
await subject.run(this.fakeJasmine, ['somedir\\somespec.js']);
expect(this.fakeJasmine.execute).toHaveBeenCalledWith(['somedir\\somespec.js'], undefined);
});
});
});
});
// Adapted from Sindre Sorhus's escape-string-regexp (MIT license)
function escapeStringForRegexp(string) {
// Escape characters with special meaning either inside or outside character sets.
// Use a simple backslash escape when it’s always valid, and a `\xnn` escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
return string
.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
.replace(/-/g, '\\x2d');
}
jasmine-npm-4.5.0/spec/filters/ 0000775 0000000 0000000 00000000000 14327321345 0016344 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/filters/console_spec_filter_spec.js 0000664 0000000 0000000 00000001560 14327321345 0023737 0 ustar 00root root 0000000 0000000 const ConsoleSpecFilter = require('../../lib/filters/console_spec_filter');
describe("ConsoleSpecFilter", function() {
it("should match when no string is provided", function() {
const specFilter = new ConsoleSpecFilter();
expect(specFilter.matches("foo")).toBe(true);
expect(specFilter.matches("*bar")).toBe(true);
});
it("should match the provided string", function() {
const specFilter = new ConsoleSpecFilter({
filterString: "foo"
});
expect(specFilter.matches("foo")).toBe(true);
expect(specFilter.matches("bar")).toBe(false);
});
it("should match by part of spec name", function() {
const specFilter = new ConsoleSpecFilter({
filterString: "ba"
});
expect(specFilter.matches("foo")).toBe(false);
expect(specFilter.matches("bar")).toBe(true);
expect(specFilter.matches("baz")).toBe(true);
});
});
jasmine-npm-4.5.0/spec/fixtures/ 0000775 0000000 0000000 00000000000 14327321345 0016545 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/badReporter.js 0000664 0000000 0000000 00000000000 14327321345 0021342 0 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/cjs-load-exception/ 0000775 0000000 0000000 00000000000 14327321345 0022235 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/cjs-load-exception/jasmine.json 0000664 0000000 0000000 00000000126 14327321345 0024555 0 ustar 00root root 0000000 0000000 {
"spec_dir": ".",
"spec_files": [
"throws_on_load.js"
],
"helpers": []
}
jasmine-npm-4.5.0/spec/fixtures/cjs-load-exception/throws_on_load.js 0000664 0000000 0000000 00000000031 14327321345 0025606 0 ustar 00root root 0000000 0000000 throw new Error("nope");
jasmine-npm-4.5.0/spec/fixtures/cjs-syntax-error/ 0000775 0000000 0000000 00000000000 14327321345 0021777 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/cjs-syntax-error/jasmine.json 0000664 0000000 0000000 00000000124 14327321345 0024315 0 ustar 00root root 0000000 0000000 {
"spec_dir": ".",
"spec_files": [
"syntax_error.js"
],
"helpers": []
}
jasmine-npm-4.5.0/spec/fixtures/cjs-syntax-error/syntax_error.js 0000664 0000000 0000000 00000000012 14327321345 0025065 0 ustar 00root root 0000000 0000000 function(
jasmine-npm-4.5.0/spec/fixtures/customReporter.js 0000664 0000000 0000000 00000000047 14327321345 0022141 0 ustar 00root root 0000000 0000000 module.exports = function Report() {};
jasmine-npm-4.5.0/spec/fixtures/customReporter.mjs 0000664 0000000 0000000 00000000275 14327321345 0022321 0 ustar 00root root 0000000 0000000 export default function Reporter() {}
Reporter.prototype.jasmineDone = function() {
console.log('customReporter.mjs jasmineDone');
};
Reporter.prototype.isCustomReporterDotMjs = true; jasmine-npm-4.5.0/spec/fixtures/defaultProgrammaticFail.js 0000664 0000000 0000000 00000000210 14327321345 0023662 0 ustar 00root root 0000000 0000000 const Jasmine = require('../..');
const jasmine = new Jasmine();
it('fails', function() {
expect(1).toBe(2);
});
jasmine.execute();
jasmine-npm-4.5.0/spec/fixtures/dontExitOnCompletion.js 0000664 0000000 0000000 00000000362 14327321345 0023231 0 ustar 00root root 0000000 0000000 const Jasmine = require('../..');
const jasmine = new Jasmine();
it('a spec', function() {});
jasmine.exitOnCompletion = false;
jasmine.execute().finally(function() {
setTimeout(function() {
console.log("in setTimeout cb");
});
});
jasmine-npm-4.5.0/spec/fixtures/env-config/ 0000775 0000000 0000000 00000000000 14327321345 0020600 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/env-config/aSpec.js 0000664 0000000 0000000 00000000144 14327321345 0022170 0 ustar 00root root 0000000 0000000 for (let i = 1; i <= 5; i++) {
it('spec 1', function() {
console.log('in spec ' + i);
});
}
jasmine-npm-4.5.0/spec/fixtures/env-config/jasmine.json 0000664 0000000 0000000 00000000130 14327321345 0023113 0 ustar 00root root 0000000 0000000 {
"spec_dir": ".",
"spec_files": ["aSpec.js"],
"env": {
"random": false
}
}
jasmine-npm-4.5.0/spec/fixtures/esm-importing-commonjs-syntax-error/ 0000775 0000000 0000000 00000000000 14327321345 0025635 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/esm-importing-commonjs-syntax-error/intermediate.js 0000664 0000000 0000000 00000000033 14327321345 0030641 0 ustar 00root root 0000000 0000000 require('./syntax_error');
jasmine-npm-4.5.0/spec/fixtures/esm-importing-commonjs-syntax-error/jasmine.json 0000664 0000000 0000000 00000000115 14327321345 0030153 0 ustar 00root root 0000000 0000000 {
"spec_dir": ".",
"spec_files": [
"spec.mjs"
],
"helpers": []
}
jasmine-npm-4.5.0/spec/fixtures/esm-importing-commonjs-syntax-error/spec.mjs 0000664 0000000 0000000 00000000043 14327321345 0027277 0 ustar 00root root 0000000 0000000 await import('./intermediate.js');
jasmine-npm-4.5.0/spec/fixtures/esm-importing-commonjs-syntax-error/syntax_error.js 0000664 0000000 0000000 00000000002 14327321345 0030722 0 ustar 00root root 0000000 0000000 {
jasmine-npm-4.5.0/spec/fixtures/esm-indirect-error/ 0000775 0000000 0000000 00000000000 14327321345 0022257 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/esm-indirect-error/jasmine.json 0000664 0000000 0000000 00000000115 14327321345 0024575 0 ustar 00root root 0000000 0000000 {
"spec_dir": ".",
"spec_files": [
"spec.mjs"
],
"helpers": []
}
jasmine-npm-4.5.0/spec/fixtures/esm-indirect-error/spec.mjs 0000664 0000000 0000000 00000000060 14327321345 0023720 0 ustar 00root root 0000000 0000000 import './throws.mjs';
it('a spec', () => {});
jasmine-npm-4.5.0/spec/fixtures/esm-indirect-error/throws.mjs 0000664 0000000 0000000 00000000031 14327321345 0024312 0 ustar 00root root 0000000 0000000 throw new Error('nope');
jasmine-npm-4.5.0/spec/fixtures/esm-load-exception/ 0000775 0000000 0000000 00000000000 14327321345 0022242 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/esm-load-exception/jasmine.json 0000664 0000000 0000000 00000000127 14327321345 0024563 0 ustar 00root root 0000000 0000000 {
"spec_dir": ".",
"spec_files": [
"throws_on_load.mjs"
],
"helpers": []
}
jasmine-npm-4.5.0/spec/fixtures/esm-load-exception/throws_on_load.mjs 0000664 0000000 0000000 00000000031 14327321345 0025770 0 ustar 00root root 0000000 0000000 throw new Error("nope");
jasmine-npm-4.5.0/spec/fixtures/esm-reporter-packagejson/ 0000775 0000000 0000000 00000000000 14327321345 0023454 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/esm-reporter-packagejson/customReporter.js 0000664 0000000 0000000 00000000212 14327321345 0027042 0 ustar 00root root 0000000 0000000 export default function Reporter() {}
Reporter.prototype.jasmineDone = function() {
console.log('customReporter.js jasmineDone');
};
jasmine-npm-4.5.0/spec/fixtures/esm-reporter-packagejson/jasmine.json 0000664 0000000 0000000 00000000105 14327321345 0025771 0 ustar 00root root 0000000 0000000 {
"spec_dir": ".",
"spec_files": [
],
"jsLoader": "import"
}
jasmine-npm-4.5.0/spec/fixtures/esm-reporter-packagejson/package.json 0000664 0000000 0000000 00000000027 14327321345 0025741 0 ustar 00root root 0000000 0000000 {
"type": "module"
}
jasmine-npm-4.5.0/spec/fixtures/esm-syntax-error/ 0000775 0000000 0000000 00000000000 14327321345 0022004 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/esm-syntax-error/jasmine.json 0000664 0000000 0000000 00000000125 14327321345 0024323 0 ustar 00root root 0000000 0000000 {
"spec_dir": ".",
"spec_files": [
"syntax_error.mjs"
],
"helpers": []
}
jasmine-npm-4.5.0/spec/fixtures/esm-syntax-error/syntax_error.mjs 0000664 0000000 0000000 00000000012 14327321345 0025247 0 ustar 00root root 0000000 0000000 function(
jasmine-npm-4.5.0/spec/fixtures/esm/ 0000775 0000000 0000000 00000000000 14327321345 0017331 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/esm/commonjs_helper.js 0000664 0000000 0000000 00000000100 14327321345 0023042 0 ustar 00root root 0000000 0000000 console.log('commonjs_helper');
require('./commonjs_sentinel');
jasmine-npm-4.5.0/spec/fixtures/esm/commonjs_sentinel.js 0000664 0000000 0000000 00000000101 14327321345 0023405 0 ustar 00root root 0000000 0000000 // An empty module that we can require, to see if require works.
jasmine-npm-4.5.0/spec/fixtures/esm/commonjs_spec.js 0000664 0000000 0000000 00000000227 14327321345 0022527 0 ustar 00root root 0000000 0000000 describe('A spec file ending in .js', function() {
it('is required as a commonjs module', function() {
require('./commonjs_sentinel');
});
});
jasmine-npm-4.5.0/spec/fixtures/esm/esm_helper.mjs 0000664 0000000 0000000 00000000070 14327321345 0022164 0 ustar 00root root 0000000 0000000 import './esm_sentinel.mjs';
console.log('esm_helper');
jasmine-npm-4.5.0/spec/fixtures/esm/esm_sentinel.mjs 0000664 0000000 0000000 00000000120 14327321345 0022522 0 ustar 00root root 0000000 0000000 // An empty module that will fail if loaded via require(), due to its extension
jasmine-npm-4.5.0/spec/fixtures/esm/esm_spec.mjs 0000664 0000000 0000000 00000000544 14327321345 0021645 0 ustar 00root root 0000000 0000000 describe('A spec file ending in .mjs', function() {
it('is imported as an es module', function() {
// Node probably threw already if we tried to require this file,
// but check anyway just to be sure.
expect(function() {
require('./commonjs_sentinel');
}).toThrowError(/require is not defined/);
});
});
jasmine-npm-4.5.0/spec/fixtures/esm/jasmine.mjs 0000664 0000000 0000000 00000000426 14327321345 0021474 0 ustar 00root root 0000000 0000000 const config = {
"spec_dir": ".",
"spec_files": [
"commonjs_spec.js",
"esm_spec.mjs"
],
"helpers": [
"name_reporter.js",
"commonjs_helper.js",
"esm_helper.mjs"
],
"stopSpecOnExpectationFailure": false,
"random": false
};
export default config;
jasmine-npm-4.5.0/spec/fixtures/esm/name_reporter.js 0000664 0000000 0000000 00000000267 14327321345 0022536 0 ustar 00root root 0000000 0000000 console.log('name_reporter');
beforeAll(function() {
jasmine.getEnv().addReporter({
specStarted: function (event) {
console.log('Spec:', event.fullName);
}
});
});
jasmine-npm-4.5.0/spec/fixtures/example/ 0000775 0000000 0000000 00000000000 14327321345 0020200 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/example/lib/ 0000775 0000000 0000000 00000000000 14327321345 0020746 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/example/lib/jasmine_examples/ 0000775 0000000 0000000 00000000000 14327321345 0024272 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/example/lib/jasmine_examples/Bar.js 0000664 0000000 0000000 00000000000 14327321345 0025322 0 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/example/lib/jasmine_examples/Foo.js 0000664 0000000 0000000 00000000000 14327321345 0025341 0 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/example/spec/ 0000775 0000000 0000000 00000000000 14327321345 0021132 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/example/spec/helpers/ 0000775 0000000 0000000 00000000000 14327321345 0022574 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/example/spec/helpers/jasmine_examples/ 0000775 0000000 0000000 00000000000 14327321345 0026120 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/example/spec/helpers/jasmine_examples/SpecHelper.js 0000664 0000000 0000000 00000000000 14327321345 0030476 0 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/example/spec/jasmine_examples/ 0000775 0000000 0000000 00000000000 14327321345 0024456 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/example/spec/jasmine_examples/FooSpec.js 0000664 0000000 0000000 00000000000 14327321345 0026340 0 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/import-jsx/ 0000775 0000000 0000000 00000000000 14327321345 0020661 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/import-jsx/jasmine.json 0000664 0000000 0000000 00000000115 14327321345 0023177 0 ustar 00root root 0000000 0000000 {
"spec_dir": ".",
"spec_files": [
"spec.jsx"
],
"helpers": []
}
jasmine-npm-4.5.0/spec/fixtures/import-jsx/spec.jsx 0000664 0000000 0000000 00000000041 14327321345 0022334 0 ustar 00root root 0000000 0000000 it('is a spec', function() {
});
jasmine-npm-4.5.0/spec/fixtures/jasmine_spec/ 0000775 0000000 0000000 00000000000 14327321345 0021205 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/jasmine_spec/c.js 0000664 0000000 0000000 00000000000 14327321345 0021753 0 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/jasmine_spec/d.js 0000664 0000000 0000000 00000000000 14327321345 0021754 0 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/jasmine_spec/e.js 0000664 0000000 0000000 00000000000 14327321345 0021755 0 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/jasmine_spec/f.js 0000664 0000000 0000000 00000000000 14327321345 0021756 0 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/js-loader-default/ 0000775 0000000 0000000 00000000000 14327321345 0022047 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/js-loader-default/anEsModule.js 0000664 0000000 0000000 00000000047 14327321345 0024442 0 ustar 00root root 0000000 0000000 export function foo() {
return 42;
}
jasmine-npm-4.5.0/spec/fixtures/js-loader-default/anEsModuleSpec.js 0000664 0000000 0000000 00000000214 14327321345 0025251 0 ustar 00root root 0000000 0000000 import {foo} from './anEsModule.js';
describe('foo', function() {
it('returns 42', function() {
expect(foo()).toEqual(42);
});
});
jasmine-npm-4.5.0/spec/fixtures/js-loader-default/anEsRequire.js 0000664 0000000 0000000 00000000032 14327321345 0024623 0 ustar 00root root 0000000 0000000 import './anEsModule.js';
jasmine-npm-4.5.0/spec/fixtures/js-loader-default/jasmine.json 0000664 0000000 0000000 00000000164 14327321345 0024371 0 ustar 00root root 0000000 0000000 {
"spec_dir": ".",
"spec_files": ["anEsModuleSpec.js"],
"requires": ["../js-loader-default/anEsRequire.js"]
}
jasmine-npm-4.5.0/spec/fixtures/js-loader-default/package.json 0000664 0000000 0000000 00000000027 14327321345 0024334 0 ustar 00root root 0000000 0000000 {
"type": "module"
}
jasmine-npm-4.5.0/spec/fixtures/js-loader-import/ 0000775 0000000 0000000 00000000000 14327321345 0021735 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/js-loader-import/anEsModule.js 0000664 0000000 0000000 00000000047 14327321345 0024330 0 ustar 00root root 0000000 0000000 export function foo() {
return 42;
}
jasmine-npm-4.5.0/spec/fixtures/js-loader-import/anEsModuleSpec.js 0000664 0000000 0000000 00000000214 14327321345 0025137 0 ustar 00root root 0000000 0000000 import {foo} from './anEsModule.js';
describe('foo', function() {
it('returns 42', function() {
expect(foo()).toEqual(42);
});
});
jasmine-npm-4.5.0/spec/fixtures/js-loader-import/anEsRequire.js 0000664 0000000 0000000 00000000032 14327321345 0024511 0 ustar 00root root 0000000 0000000 import './anEsModule.js';
jasmine-npm-4.5.0/spec/fixtures/js-loader-import/anotherEsModuleSpec.js 0000664 0000000 0000000 00000000214 14327321345 0026201 0 ustar 00root root 0000000 0000000 import {foo} from './anEsModule.js';
describe('foo', function() {
it('returns 42', function() {
expect(foo()).toEqual(42);
});
});
jasmine-npm-4.5.0/spec/fixtures/js-loader-import/jasmine.json 0000664 0000000 0000000 00000000213 14327321345 0024252 0 ustar 00root root 0000000 0000000 {
"spec_dir": ".",
"spec_files": ["anEsModuleSpec.js"],
"requires": ["../js-loader-import/anEsRequire.js"],
"jsLoader": "import"
}
jasmine-npm-4.5.0/spec/fixtures/js-loader-import/package.json 0000664 0000000 0000000 00000000027 14327321345 0024222 0 ustar 00root root 0000000 0000000 {
"type": "module"
}
jasmine-npm-4.5.0/spec/fixtures/js-loader-require/ 0000775 0000000 0000000 00000000000 14327321345 0022077 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/js-loader-require/aRequire.js 0000664 0000000 0000000 00000000125 14327321345 0024210 0 ustar 00root root 0000000 0000000 if (!module.parent) {
throw new Error('aRequire.js was loaded as an ES module');
}
jasmine-npm-4.5.0/spec/fixtures/js-loader-require/aSpec.js 0000664 0000000 0000000 00000000231 14327321345 0023464 0 ustar 00root root 0000000 0000000 describe('a file with js extension', function() {
it('was loaded as a CommonJS module', function() {
expect(module.parent).toBeTruthy();
});
});
jasmine-npm-4.5.0/spec/fixtures/js-loader-require/jasmine.json 0000664 0000000 0000000 00000000217 14327321345 0024420 0 ustar 00root root 0000000 0000000 {
"spec_dir": ".",
"spec_files": ["aSpec.js"],
"requires": ["../spec/fixtures/js-loader-require/aRequire.js"],
"jsLoader": "require"
}
jasmine-npm-4.5.0/spec/fixtures/no-globals/ 0000775 0000000 0000000 00000000000 14327321345 0020602 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/no-globals/aSpec.js 0000664 0000000 0000000 00000000237 14327321345 0022175 0 ustar 00root root 0000000 0000000 const {it, expect} = require('jasmine-core').noGlobals();
it('can use equality testers defined in a different file', function() {
expect(1).toEqual(2);
});
jasmine-npm-4.5.0/spec/fixtures/no-globals/runner.js 0000664 0000000 0000000 00000001272 14327321345 0022453 0 ustar 00root root 0000000 0000000 const initialGlobals = Object.keys(global);
const Jasmine = require('../../../lib/jasmine.js');
const {jasmine, beforeEach} = require('jasmine-core').noGlobals();
beforeEach(function() {
jasmine.addCustomEqualityTester(function(a, b) {
if ((a === 1 && b === 2) || (a === 2 && b === 1)) {
return true;
}
});
});
const runner = new Jasmine({globals: false});
runner.addSpecFile('./aSpec.js');
runner.exitOnCompletion = false;
runner.execute().then(function() {
const extraGlobals = Object.keys(global).filter(k => !initialGlobals.includes(k));
if (extraGlobals.length === 0) {
console.log('Globals OK');
} else {
console.log('Extra globals:', extraGlobals);
}
});
jasmine-npm-4.5.0/spec/fixtures/prematureExit.js 0000664 0000000 0000000 00000000207 14327321345 0021740 0 ustar 00root root 0000000 0000000 const Jasmine = require('../..');
const jasmine = new Jasmine();
it('a spec', function() {
process.exit(0);
});
jasmine.execute();
jasmine-npm-4.5.0/spec/fixtures/promiseFailure.js 0000664 0000000 0000000 00000000432 14327321345 0022070 0 ustar 00root root 0000000 0000000 const Jasmine = require('../..');
const jasmine = new Jasmine();
it('a spec', function() {
expect(1).toBe(2);
});
jasmine.exitOnCompletion = false;
jasmine.execute().then(function(result) {
if (result.overallStatus === 'failed') {
console.log("Promise failure!");
}
});
jasmine-npm-4.5.0/spec/fixtures/promiseIncomplete.js 0000664 0000000 0000000 00000000460 14327321345 0022601 0 ustar 00root root 0000000 0000000 const Jasmine = require('../..');
const jasmine = new Jasmine();
it('a spec', function() {});
fit('another spec', function() {});
jasmine.exitOnCompletion = false;
jasmine.execute().then(function(result) {
if (result.overallStatus === 'incomplete') {
console.log("Promise incomplete!");
}
});
jasmine-npm-4.5.0/spec/fixtures/promiseSuccess.js 0000664 0000000 0000000 00000000404 14327321345 0022110 0 ustar 00root root 0000000 0000000 const Jasmine = require('../..');
const jasmine = new Jasmine();
it('a spec', function() {});
jasmine.exitOnCompletion = false;
jasmine.execute().then(function(result) {
if (result.overallStatus === 'passed') {
console.log("Promise success!");
}
});
jasmine-npm-4.5.0/spec/fixtures/require_tester.js 0000664 0000000 0000000 00000000076 14327321345 0022150 0 ustar 00root root 0000000 0000000 global.require_tester_was_loaded = true;
module.exports = {};
jasmine-npm-4.5.0/spec/fixtures/sample_project/ 0000775 0000000 0000000 00000000000 14327321345 0021554 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/sample_project/spec/ 0000775 0000000 0000000 00000000000 14327321345 0022506 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/sample_project/spec/fixture_spec.js 0000664 0000000 0000000 00000000000 14327321345 0025532 0 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/sample_project/spec/helper.js 0000664 0000000 0000000 00000000000 14327321345 0024311 0 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/sample_project/spec/other_fixture_spec.js 0000664 0000000 0000000 00000000000 14327321345 0026733 0 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/sample_project/spec/support/ 0000775 0000000 0000000 00000000000 14327321345 0024222 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/fixtures/sample_project/spec/support/jasmine.json 0000664 0000000 0000000 00000000106 14327321345 0026540 0 ustar 00root root 0000000 0000000 {
"spec_dir": "spec",
"spec_files": [
"fixture_spec.js"
]
}
jasmine-npm-4.5.0/spec/fixtures/sample_project/spec/support/jasmine_alternate.cjs 0000664 0000000 0000000 00000000273 14327321345 0030412 0 ustar 00root root 0000000 0000000 module.exports = {
"spec_dir": "spec",
"spec_files": [
"fixture_spec.js",
"**/*spec.js"
],
"helpers": [
"helper.js"
],
"requires": [
"ts-node/register"
]
};
jasmine-npm-4.5.0/spec/fixtures/sample_project/spec/support/jasmine_alternate.json 0000664 0000000 0000000 00000000251 14327321345 0030600 0 ustar 00root root 0000000 0000000 {
"spec_dir": "spec",
"spec_files": [
"fixture_spec.js",
"**/*spec.js"
],
"helpers": [
"helper.js"
],
"requires": [
"ts-node/register"
]
}
jasmine-npm-4.5.0/spec/fixtures/sample_project/spec/support/jasmine_alternate.mjs 0000664 0000000 0000000 00000000357 14327321345 0030427 0 ustar 00root root 0000000 0000000 const config = {
"spec_dir": "spec",
"spec_files": [
"fixture_spec.js",
"**/*spec.js"
],
"helpers": [
"helper.js"
],
"requires": [
"ts-node/register"
]
};
export default config;
jasmine-npm-4.5.0/spec/fixtures/topLevelAwaitSentinel.mjs 0000664 0000000 0000000 00000000031 14327321345 0023534 0 ustar 00root root 0000000 0000000 await Promise.resolve();
jasmine-npm-4.5.0/spec/integration_spec.js 0000664 0000000 0000000 00000017724 14327321345 0020602 0 ustar 00root root 0000000 0000000 const child_process = require('child_process');
describe('Integration', function () {
beforeEach(function() {
jasmine.addMatchers({
toBeSuccess: function(matchersUtil) {
return {
compare: function(actual, expected) {
const result = { pass: actual.exitCode === 0 };
if (result.pass) {
result.message = 'Expected process not to succeed but it did.';
} else {
result.message = `Expected process to succeed but it exited ${actual.exitCode}.`;
}
result.message += '\n\nOutput:\n' + actual.output;
return result;
}
};
}
});
});
it('supports ES modules', async function () {
const {exitCode, output} = await runJasmine('spec/fixtures/esm', 'jasmine.mjs');
expect(exitCode).toEqual(0);
expect(stripExperimentalModulesWarning(output)).toContain(
'name_reporter\n' +
'commonjs_helper\n' +
'esm_helper\n' +
'Started\n' +
'Spec: A spec file ending in .js is required as a commonjs module\n' +
'.Spec: A spec file ending in .mjs is imported as an es module\n'
);
});
it('supports ES module reporters that end in .mjs', async function() {
let {output} = await runJasmine(
'spec/fixtures/sample_project',
'spec/support/jasmine.json',
['--reporter=../customReporter.mjs']
);
expect(output).toContain('customReporter.mjs jasmineDone');
});
it('supports ES module reporters that end in .js', async function() {
let {output} = await runJasmine(
'spec/fixtures/esm-reporter-packagejson',
'jasmine.json',
['--reporter=./customReporter.js']
);
expect(output).toContain('customReporter.js jasmineDone');
});
it('loads .js files using import when jsLoader is "import"', async function() {
expect(await runJasmine('spec/fixtures/js-loader-import')).toBeSuccess();
});
it('loads .js files using require when jsLoader is "require"', async function() {
expect(await runJasmine('spec/fixtures/js-loader-require')).toBeSuccess();
});
it('loads .js files using import when jsLoader is undefined', async function() {
expect(await runJasmine('spec/fixtures/js-loader-default')).toBeSuccess();
});
it('falls back to require when loading extensions that import does not support', async function() {
expect(await runJasmine('spec/fixtures/import-jsx')).toBeSuccess();
});
it('handles load-time exceptions from CommonJS specs properly', async function () {
const {exitCode, output} = await runJasmine('spec/fixtures/cjs-load-exception');
expect(exitCode).toEqual(1);
expect(output).toContain('Error: nope');
expect(output).toMatch(/at .*throws_on_load.js/);
});
it('handles load-time exceptions from ESM specs properly', async function () {
const {exitCode, output} = await runJasmine('spec/fixtures/esm-load-exception');
expect(exitCode).toEqual(1);
expect(output).toContain('Error: nope');
expect(output).toMatch(/at .*throws_on_load.mjs/);
});
it('handles syntax errors in CommonJS specs properly', async function () {
const {exitCode, output} = await runJasmine('spec/fixtures/cjs-syntax-error');
expect(exitCode).toEqual(1);
expect(output).toContain('SyntaxError');
expect(output).toContain('syntax_error.js');
});
it('handles syntax errors in ESM specs properly', async function () {
const {exitCode, output} = await runJasmine('spec/fixtures/esm-syntax-error');
expect(exitCode).toEqual(1);
expect(output).toContain('SyntaxError');
expect(output).toContain('syntax_error.mjs');
});
it('handles syntax errors from a CommonJS module loaded from an ESM spec properly', async function() {
try {
await import('./fixtures/topLevelAwaitSentinel.mjs');
} catch (e) {
if (e instanceof SyntaxError && e.message === 'Unexpected reserved word') {
pending('This Node version does not support top-level await');
} else if (e.message === 'Not supported') {
pending('This Node version does not support dynamic import');
} else {
throw e;
}
}
const {exitCode, output} = await runJasmine('spec/fixtures/esm-importing-commonjs-syntax-error');
expect(exitCode).toEqual(1);
expect(output).toContain('SyntaxError');
expect(output).toContain('syntax_error.js');
});
it('handles exceptions thrown from a module loaded from an ESM spec properly', async function() {
const {exitCode, output} = await runJasmine('spec/fixtures/esm-indirect-error');
expect(exitCode).toEqual(1);
expect(output).toContain('nope');
expect(output).toContain('throws.mjs');
});
it('can configure the env via the `env` config property', async function() {
const {exitCode, output} = await runJasmine('spec/fixtures/env-config');
expect(exitCode).toEqual(0);
expect(stripExperimentalModulesWarning(output)).toContain(
'in spec 1\n.in spec 2\n.in spec 3\n.in spec 4\n.in spec 5'
);
});
describe('Programmatic usage', function() {
it('exits on completion by default', async function() {
const {exitCode, output} = await runCommand('node', ['spec/fixtures/defaultProgrammaticFail.js']);
expect(exitCode).toEqual(3);
expect(output).toContain('1 spec, 1 failure');
});
it('does not exit on completion when exitOnCompletion is set to false', async function() {
const {exitCode, output} = await runCommand('node', ['spec/fixtures/dontExitOnCompletion.js']);
expect(exitCode).toEqual(0);
expect(output).toContain('in setTimeout cb');
});
it('resolves the returned promise when the suite passes', async function() {
const {exitCode, output} = await runCommand('node', ['spec/fixtures/promiseSuccess.js']);
expect(exitCode).toEqual(0);
expect(output).toContain('Promise success!');
});
it('resolves the returned promise when the suite fails', async function() {
const {exitCode, output} = await runCommand('node', ['spec/fixtures/promiseFailure.js']);
expect(exitCode).toEqual(0);
expect(output).toContain('Promise failure!');
});
it('resolves the returned promise when the suite is incomplete', async function() {
const {exitCode, output} = await runCommand('node', ['spec/fixtures/promiseIncomplete.js']);
expect(exitCode).toEqual(0);
expect(output).toContain('Promise incomplete!');
});
});
it('exits with status 4 when exit() is called before the suite finishes', async function() {
const {exitCode} = await runCommand('node', ['spec/fixtures/prematureExit.js']);
expect(exitCode).toEqual(4);
});
it('does not create globals when the globals option is false', async function() {
const {exitCode, output} = await runCommand('node', ['runner.js'], 'spec/fixtures/no-globals');
expect(exitCode).toEqual(0);
expect(output).toContain('1 spec, 0 failures');
expect(output).toContain('Globals OK');
});
});
async function runJasmine(cwd, config="jasmine.json", extraArgs = []) {
const args = ['../../../bin/jasmine.js', '--config=' + config].concat(extraArgs);
return runCommand('node', args, cwd);
}
async function runCommand(cmd, args, cwd = '.') {
return new Promise(function(resolve) {
const child = child_process.spawn(
cmd,
args,
{
cwd,
shell: false
}
);
let output = '';
child.stdout.on('data', function (data) {
output += data;
});
child.stderr.on('data', function (data) {
output += data;
});
child.on('close', function (exitCode) {
resolve({exitCode, output});
});
});
}
function stripExperimentalModulesWarning(jasmineOutput) {
// Node < 14 outputs a warning when ES modules are used, e.g.:
// (node:5258) ExperimentalWarning: The ESM module loader is experimental.
// The position of this warning in the output varies. Sometimes it
// occurs before the lines we're interested in but sometimes it's in
// the middle of them.
return jasmineOutput.replace(/^.*ExperimentalWarning.*$\n/m, '');
}
jasmine-npm-4.5.0/spec/jasmine_spec.js 0000664 0000000 0000000 00000067465 14327321345 0017714 0 ustar 00root root 0000000 0000000 const path = require('path');
const slash = require('slash');
const Jasmine = require('../lib/jasmine');
const Loader = require("../lib/loader");
describe('Jasmine', function() {
beforeEach(function() {
this.bootedJasmine = {
getEnv: jasmine.createSpy('getEnv').and.returnValue({
addReporter: jasmine.createSpy('addReporter'),
clearReporters: jasmine.createSpy('clearReporters'),
addMatchers: jasmine.createSpy('addMatchers'),
provideFallbackReporter: jasmine.createSpy('provideFallbackReporter'),
execute: jasmine.createSpy('execute')
.and.callFake(function(ignored, callback) {
callback();
}),
configure: jasmine.createSpy('configure')
}),
Timer: jasmine.createSpy('Timer')
};
this.fakeJasmineCore = {
boot: jasmine.createSpy('boot').and.returnValue(this.bootedJasmine),
files: {
path: 'fake/jasmine/path'
}
};
this.testJasmine = new Jasmine({ jasmineCore: this.fakeJasmineCore });
this.testJasmine.exit = function() {
// Don't actually exit the node process
};
this.execute = async function(options = {}) {
const overallStatus = options.overallStatus || 'passed';
const executeArgs = options.executeArgs || [];
let executePromise;
let resolveEnvExecutePromise;
const envExecutePromise = new Promise(resolve => {
resolveEnvExecutePromise = resolve;
});
await new Promise(resolve => {
this.testJasmine.env.execute.and.callFake(function() {
resolve();
return envExecutePromise;
});
executePromise = this.testJasmine.execute.apply(this.testJasmine, executeArgs);
});
resolveEnvExecutePromise({overallStatus});
return executePromise;
};
});
describe('constructor options', function() {
it('have defaults', function() {
expect(this.testJasmine.projectBaseDir).toEqual(path.resolve());
});
});
describe('#addSpecFile', function() {
it('adds the provided path to the list of spec files', function () {
expect(this.testJasmine.specFiles).toEqual([]);
this.testJasmine.addSpecFile('some/file/path.js');
expect(this.testJasmine.specFiles).toEqual(['some/file/path.js']);
});
});
describe('#addHelperFile', function() {
it('adds the provided path to the list of helper files', function () {
expect(this.testJasmine.helperFiles).toEqual([]);
this.testJasmine.addHelperFile('some/file/path.js');
expect(this.testJasmine.helperFiles).toEqual(['some/file/path.js']);
});
});
describe('Methods that specify files via globs', function() {
describe('#addMatchingSpecFiles', function() {
hasCommonFileGlobBehavior('addMatchingSpecFiles', 'specFiles');
});
describe('#addMatchingHelperFiles', function() {
hasCommonFileGlobBehavior('addMatchingHelperFiles', 'helperFiles');
});
function hasCommonFileGlobBehavior(method, destProp) {
it('adds a file with an absolute path', function() {
const aFile = path.join(this.testJasmine.projectBaseDir, this.testJasmine.specDir, 'spec/command_spec.js')
.replace(/\\/g, '/');
expect(this.testJasmine[destProp]).toEqual([]);
this.testJasmine[method]([aFile]);
expect(this.testJasmine[destProp]).toEqual([slash(aFile)]);
});
it('adds files that match a glob pattern', function() {
expect(this.testJasmine[destProp]).toEqual([]);
this.testJasmine[method](['spec/fixtures/jasmine_spec/*.js']);
expect(this.testJasmine[destProp].map(basename)).toEqual([
'c.js',
'd.js',
'e.js',
'f.js',
]);
});
it('can exclude files that match another glob', function() {
expect(this.testJasmine[destProp]).toEqual([]);
this.testJasmine[method]([
'spec/fixtures/jasmine_spec/*.js',
'!spec/fixtures/jasmine_spec/c*'
]);
expect(this.testJasmine[destProp].map(basename)).toEqual([
'd.js',
'e.js',
'f.js',
]);
});
it('adds new files to existing files', function() {
const aFile = path.join(this.testJasmine.projectBaseDir, this.testJasmine.specDir, 'spec/command_spec.js');
this.testJasmine[destProp] = [aFile, 'b'];
this.testJasmine[method](['spec/fixtures/jasmine_spec/*.js']);
expect(this.testJasmine[destProp].map(basename)).toEqual([
'command_spec.js',
'b',
'c.js',
'd.js',
'e.js',
'f.js',
]);
});
}
function basename(name) { return path.basename(name); }
});
it('delegates #coreVersion to jasmine-core', function() {
this.fakeJasmineCore.version = jasmine.createSpy('coreVersion').and.returnValue('a version');
expect(this.testJasmine.coreVersion()).toEqual('a version');
});
it('registers a console reporter upon construction', function() {
spyOn(Jasmine, 'ConsoleReporter').and.returnValue({someProperty: 'some value'});
const testJasmine = new Jasmine({ jasmineCore: this.fakeJasmineCore });
expect(testJasmine.env.addReporter).toHaveBeenCalledWith({someProperty: 'some value'});
});
it('exposes #addReporter and #clearReporters', function() {
const testJasmine = new Jasmine({ jasmineCore: this.fakeJasmineCore });
expect(testJasmine.reportersCount).toEqual(1);
testJasmine.clearReporters();
expect(testJasmine.reportersCount).toEqual(0);
expect(testJasmine.env.clearReporters).toHaveBeenCalled();
testJasmine.addReporter({someProperty: 'some value'});
expect(testJasmine.reportersCount).toEqual(1);
expect(testJasmine.env.addReporter).toHaveBeenCalledWith({someProperty: 'some value'});
});
describe('#configureDefaultReporter', function() {
beforeEach(function() {
spyOn(this.testJasmine.reporter, 'setOptions');
});
it('sets the options on the console reporter', function() {
const reporterOptions = {
print: 'printer',
showColors: true,
};
const expectedReporterOptions = Object.keys(reporterOptions).reduce(function(options, key) {
options[key] = reporterOptions[key];
return options;
}, {});
this.testJasmine.configureDefaultReporter(reporterOptions);
expect(this.testJasmine.reporter.setOptions).toHaveBeenCalledWith(expectedReporterOptions);
});
it('creates a reporter with a default option if an option is not specified', function() {
const reporterOptions = {};
this.testJasmine.configureDefaultReporter(reporterOptions);
const expectedReporterOptions = {
print: jasmine.any(Function),
showColors: true,
};
expect(this.testJasmine.reporter.setOptions).toHaveBeenCalledWith(expectedReporterOptions);
});
});
it('adds matchers to the jasmine env', function() {
this.testJasmine.addMatchers(['fake matcher 1', 'fake matcher 2']);
expect(this.testJasmine.env.addMatchers).toHaveBeenCalledWith(['fake matcher 1', 'fake matcher 2']);
});
describe('loading configurations', function() {
beforeEach(function() {
this.fixtureJasmine = new Jasmine({
jasmineCore: this.fakeJasmineCore,
projectBaseDir: 'spec/fixtures/sample_project'
});
});
describe('from an object', function() {
beforeEach(function() {
this.loader = this.fixtureJasmine.loader = jasmine.createSpyObj('loader', ['load']);
this.configObject = {
spec_dir: "spec",
spec_files: [
"fixture_spec.js",
"**/*spec.js"
],
helpers: [
"helper.js"
],
requires: [
"ts-node/register"
]
};
});
it('adds unique specs to the jasmine runner', function() {
this.fixtureJasmine.loadConfig(this.configObject);
expect(this.fixtureJasmine.helperFiles).toEqual(['spec/fixtures/sample_project/spec/helper.js']);
expect(this.fixtureJasmine.requires).toEqual(['ts-node/register']);
expect(this.fixtureJasmine.specFiles).toEqual([
'spec/fixtures/sample_project/spec/fixture_spec.js',
'spec/fixtures/sample_project/spec/other_fixture_spec.js'
]);
});
it('can tell jasmine-core to stop spec on no expectations', function() {
this.configObject.failSpecWithNoExpectations = true;
this.fixtureJasmine.loadConfig(this.configObject);
expect(this.fixtureJasmine.env.configure).toHaveBeenCalledWith({failSpecWithNoExpectations: true});
});
it('can tell jasmine-core to stop spec on expectation failure', function() {
this.configObject.stopSpecOnExpectationFailure = true;
this.fixtureJasmine.loadConfig(this.configObject);
expect(this.fixtureJasmine.env.configure).toHaveBeenCalledWith({stopSpecOnExpectationFailure: true});
});
it('does not configure jasmine-core for stopping spec on expectation failure by default', function() {
this.fixtureJasmine.loadConfig(this.configObject);
expect(this.fixtureJasmine.env.configure).not.toHaveBeenCalled();
});
it('can tell jasmine-core to stop execution when a spec fails', function() {
this.configObject.stopOnSpecFailure = true;
this.fixtureJasmine.loadConfig(this.configObject);
expect(this.fixtureJasmine.env.configure).toHaveBeenCalledWith({stopOnSpecFailure: true});
});
it('does not configure jasmine-core for stopping execution by default', function() {
this.fixtureJasmine.loadConfig(this.configObject);
expect(this.fixtureJasmine.env.configure).not.toHaveBeenCalled();
});
it('can tell jasmine-core to run random specs', function() {
this.configObject.random = true;
this.fixtureJasmine.loadConfig(this.configObject);
expect(this.fixtureJasmine.env.configure).toHaveBeenCalledWith({random: true});
});
it('uses jasmine-core defaults if no config options specified', function() {
this.fixtureJasmine.loadConfig(this.configObject);
expect(this.fixtureJasmine.env.configure).not.toHaveBeenCalled();
});
it('can configure the env with arbitrary properties', function() {
this.configObject.env = {someProp: 'someVal'};
this.fixtureJasmine.loadConfig(this.configObject);
expect(this.fixtureJasmine.env.configure).toHaveBeenCalledWith({someProp: 'someVal'});
});
describe('with options', function() {
it('instantiates spec_dir with the provided value', function() {
this.fixtureJasmine.loadConfig(this.configObject);
expect(this.fixtureJasmine.specDir).toEqual('spec');
});
});
describe('without options', function() {
it('falls back to an empty string with an undefined spec_dir', function() {
const config = this.configObject;
delete config.spec_dir;
this.fixtureJasmine.loadConfig(config);
expect(this.fixtureJasmine.specDir).toEqual('');
});
});
it('passes verboseDeprecations to jasmine-core when specified', function() {
this.configObject.verboseDeprecations = true;
this.fixtureJasmine.loadConfig(this.configObject);
expect(this.fixtureJasmine.env.configure).toHaveBeenCalledWith(
jasmine.objectContaining({verboseDeprecations: true})
);
});
it('does not pass verboseDeprecations to jasmine-core when not specified', function() {
this.configObject.random = true; // or set any other property
this.fixtureJasmine.loadConfig(this.configObject);
expect(this.fixtureJasmine.env.configure).toHaveBeenCalled();
expect(this.fixtureJasmine.env.configure.calls.argsFor(0)[0].verboseDeprecations)
.toBeUndefined();
});
describe('with jsLoader: "require"', function () {
it('tells the loader not to always import', async function() {
this.configObject.jsLoader = 'require';
this.fixtureJasmine.loadConfig(this.configObject);
await this.fixtureJasmine.loadSpecs();
expect(this.loader.load).toHaveBeenCalledWith(jasmine.any(String));
expect(this.loader.alwaysImport).toBeFalse();
});
});
describe('with jsLoader: "import"', function () {
it('tells the loader to always import', async function() {
this.configObject.jsLoader = 'import';
this.fixtureJasmine.loadConfig(this.configObject);
await this.fixtureJasmine.loadSpecs();
expect(this.loader.load).toHaveBeenCalledWith(jasmine.any(String));
expect(this.loader.alwaysImport).toBeTrue();
});
});
describe('with jsLoader set to an invalid value', function () {
it('throws an error', function() {
this.configObject.jsLoader = 'bogus';
expect(() => {
this.fixtureJasmine.loadConfig(this.configObject);
}).toThrowError(/"bogus" is not a valid value/);
});
});
describe('with jsLoader undefined', function () {
it('tells the loader to always import', async function() {
this.configObject.jsLoader = undefined;
this.fixtureJasmine.loadConfig(this.configObject);
await this.fixtureJasmine.loadSpecs();
expect(this.loader.load).toHaveBeenCalledWith(jasmine.any(String));
expect(this.loader.alwaysImport).toBeTrue();
});
});
it('sets alwaysListPendingSpecs when present', function() {
this.configObject.alwaysListPendingSpecs = false;
this.fixtureJasmine.loadConfig(this.configObject);
expect(this.fixtureJasmine.alwaysListPendingSpecs_).toBeFalse();
});
it('does not set alwaysListPendingSpecs when absent', function() {
delete this.configObject.alwaysListPendingSpecs;
this.fixtureJasmine.loadConfig(this.configObject);
expect(this.fixtureJasmine.alwaysListPendingSpecs_).toBeTrue();
});
it('adds specified reporters', function() {
const reporter1 = {id: 'reporter1'};
const reporter2 = {id: 'reporter2'};
this.configObject.reporters = [reporter1, reporter2];
this.fixtureJasmine.loadConfig(this.configObject);
expect(this.fixtureJasmine.env.addReporter).toHaveBeenCalledWith(reporter1);
expect(this.fixtureJasmine.env.addReporter).toHaveBeenCalledWith(reporter2);
});
});
describe('from a file', function() {
it('adds unique specs to the jasmine runner', async function() {
await this.fixtureJasmine.loadConfigFile('spec/support/jasmine_alternate.json');
expect(this.fixtureJasmine.helperFiles).toEqual(['spec/fixtures/sample_project/spec/helper.js']);
expect(this.fixtureJasmine.requires).toEqual(['ts-node/register']);
expect(this.fixtureJasmine.specFiles).toEqual([
'spec/fixtures/sample_project/spec/fixture_spec.js',
'spec/fixtures/sample_project/spec/other_fixture_spec.js'
]);
});
it('can use an ES module', async function() {
await this.fixtureJasmine.loadConfigFile('spec/support/jasmine_alternate.mjs');
expect(this.fixtureJasmine.helperFiles).toEqual(['spec/fixtures/sample_project/spec/helper.js']);
expect(this.fixtureJasmine.requires).toEqual(['ts-node/register']);
expect(this.fixtureJasmine.specFiles).toEqual([
'spec/fixtures/sample_project/spec/fixture_spec.js',
'spec/fixtures/sample_project/spec/other_fixture_spec.js'
]);
});
it('can use a CommonJS module', async function() {
await this.fixtureJasmine.loadConfigFile('spec/support/jasmine_alternate.cjs');
expect(this.fixtureJasmine.helperFiles).toEqual(['spec/fixtures/sample_project/spec/helper.js']);
expect(this.fixtureJasmine.requires).toEqual(['ts-node/register']);
expect(this.fixtureJasmine.specFiles).toEqual([
'spec/fixtures/sample_project/spec/fixture_spec.js',
'spec/fixtures/sample_project/spec/other_fixture_spec.js'
]);
});
it('loads the specified configuration file from an absolute path', async function() {
const absoluteConfigPath = path.join(__dirname, 'fixtures/sample_project/spec/support/jasmine_alternate.json');
await this.fixtureJasmine.loadConfigFile(absoluteConfigPath);
expect(this.fixtureJasmine.helperFiles).toEqual(['spec/fixtures/sample_project/spec/helper.js']);
expect(this.fixtureJasmine.requires).toEqual(['ts-node/register']);
expect(this.fixtureJasmine.specFiles).toEqual([
'spec/fixtures/sample_project/spec/fixture_spec.js',
'spec/fixtures/sample_project/spec/other_fixture_spec.js'
]);
});
it("throws an error if the specified configuration file doesn't exist", async function() {
await expectAsync(this.fixtureJasmine.loadConfigFile('missing.json')).toBeRejected();
});
it("does not throw if the default configuration files don't exist", async function() {
this.fixtureJasmine.projectBaseDir += '/missing';
await expectAsync(this.fixtureJasmine.loadConfigFile()).toBeResolved();
});
it('loads the default .json configuration file', async function() {
await this.fixtureJasmine.loadConfigFile();
expect(this.fixtureJasmine.specFiles).toEqual([
jasmine.stringMatching('^spec[\\/]fixtures[\\/]sample_project[\\/]spec[\\/]fixture_spec.js$')
]);
});
it('loads the default .js configuration file', async function() {
const config = require('./fixtures/sample_project/spec/support/jasmine.json');
spyOn(Loader.prototype, 'load').and.callFake(function(path) {
if (path.endsWith('jasmine.js')) {
return Promise.resolve(config);
} else {
const e = new Error(`Module not found: ${path}`);
e.code = 'MODULE_NOT_FOUND';
return Promise.reject(e);
}
});
await this.fixtureJasmine.loadConfigFile();
expect(Loader.prototype.load).toHaveBeenCalledWith(jasmine.stringMatching(
'jasmine\.js$'
));
expect(this.fixtureJasmine.specFiles).toEqual([
'spec/fixtures/sample_project/spec/fixture_spec.js'
]);
});
});
});
describe('#stopSpecOnExpectationFailure', function() {
it('sets the stopSpecOnExpectationFailure value on the jasmine-core env', function() {
this.testJasmine.stopSpecOnExpectationFailure('foobar');
expect(this.testJasmine.env.configure).toHaveBeenCalledWith({stopSpecOnExpectationFailure: 'foobar'});
});
});
describe('#stopOnSpecFailure', function() {
it('sets the stopOnSpecFailure value on the jasmine-core env', function() {
this.testJasmine.stopOnSpecFailure('blah');
expect(this.testJasmine.env.configure).toHaveBeenCalledWith({stopOnSpecFailure: 'blah'});
});
});
describe('#randomizeTests', function() {
it('sets the randomizeTests value on the jasmine-core env', function() {
this.testJasmine.randomizeTests('foobar');
expect(this.testJasmine.env.configure).toHaveBeenCalledWith({random: 'foobar'});
});
});
it("showing colors can be configured", function() {
expect(this.testJasmine.showingColors).toBe(true);
this.testJasmine.showColors(false);
expect(this.testJasmine.showingColors).toBe(false);
});
describe('#execute', function() {
it('uses the default console reporter if no reporters were added', async function() {
spyOn(this.testJasmine, 'configureDefaultReporter');
spyOn(this.testJasmine, 'loadSpecs');
await this.execute();
expect(this.testJasmine.configureDefaultReporter).toHaveBeenCalledWith({
showColors: true,
alwaysListPendingSpecs: true
});
expect(this.testJasmine.loadSpecs).toHaveBeenCalled();
expect(this.testJasmine.env.execute).toHaveBeenCalled();
});
it('configures the default console reporter with the right settings', async function() {
spyOn(this.testJasmine, 'configureDefaultReporter');
spyOn(this.testJasmine, 'loadSpecs');
this.testJasmine.showColors(false);
this.testJasmine.alwaysListPendingSpecs(false);
await this.execute();
expect(this.testJasmine.configureDefaultReporter).toHaveBeenCalledWith({
showColors: false,
alwaysListPendingSpecs: false
});
expect(this.testJasmine.loadSpecs).toHaveBeenCalled();
expect(this.testJasmine.env.execute).toHaveBeenCalled();
});
it('does not configure the default reporter if this was already done', async function() {
spyOn(this.testJasmine, 'loadSpecs');
this.testJasmine.configureDefaultReporter({showColors: false});
spyOn(this.testJasmine, 'configureDefaultReporter');
await this.execute();
expect(this.testJasmine.configureDefaultReporter).not.toHaveBeenCalled();
expect(this.testJasmine.loadSpecs).toHaveBeenCalled();
expect(this.testJasmine.env.execute).toHaveBeenCalled();
});
it('loads helper files before checking if any reporters were added', async function() {
const loadHelpers = spyOn(this.testJasmine, 'loadHelpers');
spyOn(this.testJasmine, 'configureDefaultReporter').and.callFake(function() {
expect(loadHelpers).toHaveBeenCalled();
});
spyOn(this.testJasmine, 'loadSpecs');
await this.execute();
expect(this.testJasmine.configureDefaultReporter).toHaveBeenCalled();
});
it('can run only specified files', async function() {
await this.execute({
executeArgs: [['spec/fixtures/sample_project/**/*spec.js']]
});
const relativePaths = this.testJasmine.specFiles.map(function(filePath) {
return slash(path.relative(__dirname, filePath));
});
expect(relativePaths).toEqual(['fixtures/sample_project/spec/fixture_spec.js', 'fixtures/sample_project/spec/other_fixture_spec.js']);
});
it('should add spec filter if filterString is provided', async function() {
await this.execute({
executeArgs: [['spec/fixtures/example/*spec.js'], 'interesting spec']
});
expect(this.testJasmine.env.configure).toHaveBeenCalledWith({specFilter: jasmine.any(Function)});
});
describe('completion behavior', function() {
beforeEach(function() {
spyOn(this.testJasmine, 'exit');
});
describe('default', function() {
it('exits successfully when the whole suite is green', async function () {
await this.execute({overallStatus: 'passed'});
expect(this.testJasmine.exit).toHaveBeenCalledWith(0);
});
it('exits with a distinct status code when anything in the suite is not green', async function () {
await this.execute({overallStatus: 'failed'});
expect(this.testJasmine.exit).toHaveBeenCalledWith(3);
});
it('exits with a distinct status code when anything in the suite is focused', async function() {
await this.execute({overallStatus: 'incomplete'});
expect(this.testJasmine.exit).toHaveBeenCalledWith(2);
});
});
describe('When exitOnCompletion is set to false', function() {
it('does not exit', async function() {
this.testJasmine.exitOnCompletion = false;
await this.execute();
expect(this.testJasmine.exit).not.toHaveBeenCalled();
});
});
});
describe('The returned promise', function() {
it('is resolved with the overall suite status', async function() {
await expectAsync(this.execute({overallStatus: 'failed'}))
.toBeResolvedTo(jasmine.objectContaining({overallStatus: 'failed'}));
});
it('is resolved with the overall suite status even if clearReporters was called', async function() {
this.testJasmine.clearReporters();
await expectAsync(this.execute({overallStatus: 'incomplete'}))
.toBeResolvedTo(jasmine.objectContaining({overallStatus: 'incomplete'}));
});
});
});
describe('When running on Windows', function() {
beforeEach(function() {
spyOn(console, 'warn');
});
function windows() {
return 'win32';
}
it('warns about backslashes in the configured project base dir', function() {
new Jasmine({
projectBaseDir: 'c:\\foo\\bar',
platform: windows,
jasmineCore: this.fakeJasmineCore,
});
expect(console.warn).toHaveBeenCalledWith('Backslashes in ' +
'file paths behave inconsistently between platforms and might not be ' +
'treated as directory separators in a future version. Consider ' +
'changing c:\\foo\\bar to c:/foo/bar.');
});
it('does not warn about backslashes in the current working directory', function() {
const jasmine = new Jasmine({
getcwd: () => 'c:\\foo\\bar',
platform: windows,
jasmineCore: this.fakeJasmineCore,
});
expect(jasmine.projectBaseDir).toEqual('c:\\foo\\bar');
expect(console.warn).not.toHaveBeenCalled();
});
it('warns about backslashes in spec_dir', function() {
const jasmine = new Jasmine({
platform: windows,
jasmineCore: this.fakeJasmineCore,
});
jasmine.loadConfig({
spec_dir: 'foo\\bar',
});
expect(console.warn).toHaveBeenCalledWith('Backslashes in ' +
'file paths behave inconsistently between platforms and might not be ' +
'treated as directory separators in a future version. Consider ' +
'changing foo\\bar to foo/bar.');
});
it('warns about backslashes in helpers', function() {
const jasmine = new Jasmine({
platform: windows,
jasmineCore: this.fakeJasmineCore,
});
jasmine.loadConfig({
helpers: ['foo\\bar']
});
expect(console.warn).toHaveBeenCalledWith('Backslashes in ' +
'file paths behave inconsistently between platforms and might not be ' +
'treated as directory separators in a future version. Consider ' +
'changing foo\\bar to foo/bar.');
jasmine.addMatchingHelperFiles(['foo\\baz']);
expect(console.warn).toHaveBeenCalledWith('Backslashes in ' +
'file paths behave inconsistently between platforms and might not be ' +
'treated as directory separators in a future version. Consider ' +
'changing foo\\baz to foo/baz.');
});
it('warns about backslashes in spec_files', function() {
const jasmine = new Jasmine({
platform: windows,
jasmineCore: this.fakeJasmineCore,
});
jasmine.loadConfig({
spec_files: ['foo\\bar']
});
expect(console.warn).toHaveBeenCalledWith('Backslashes in ' +
'file paths behave inconsistently between platforms and might not be ' +
'treated as directory separators in a future version. Consider ' +
'changing foo\\bar to foo/bar.');
jasmine.addMatchingSpecFiles(['foo\\baz']);
expect(console.warn).toHaveBeenCalledWith('Backslashes in ' +
'file paths behave inconsistently between platforms and might not be ' +
'treated as directory separators in a future version. Consider ' +
'changing foo\\baz to foo/baz.');
});
it('does not warn if no configured path contains backslashes', function() {
const jasmine = new Jasmine({
projectBaseDir: 'c:/foo/bar',
platform: windows,
jasmineCore: this.fakeJasmineCore,
});
jasmine.loadConfig({
spec_dir: 'foo/bar',
spec_files: ['baz/qux'],
helpers: ['waldo/fred']
});
expect(console.warn).not.toHaveBeenCalled();
});
});
it('does not warn about backslashes when not running on Windows', function() {
spyOn(console, 'warn');
const jasmine = new Jasmine({
projectBaseDir: 'foo\\bar',
platform: () => 'NetWare',
jasmineCore: this.fakeJasmineCore,
});
jasmine.loadConfig({
spec_dir: 'foo\\bar',
spec_files: ['baz\\qux'],
helpers: ['waldo\\fred']
});
expect(console.warn).not.toHaveBeenCalled();
});
});
jasmine-npm-4.5.0/spec/loader_spec.js 0000664 0000000 0000000 00000022402 14327321345 0017512 0 ustar 00root root 0000000 0000000 const path = require('path');
const Loader = require('../lib/loader');
describe('loader', function() {
afterEach(function() {
delete global.require_tester_was_loaded;
});
it('sets alwaysImport to true by default', function() {
expect(new Loader().alwaysImport).toBeTrue();
});
describe('#load', function() {
describe('With alwaysImport: true', function() {
describe('When the path ends in .mjs', function () {
esModuleSharedExamples('mjs', true);
});
describe('When the path does not end in .mjs', function () {
esModuleSharedExamples('js', true);
});
describe('When the extnesion is not supported by import()', function() {
it('falls back to require()', async function() {
const error = new TypeError();
error.code = 'ERR_UNKNOWN_FILE_EXTENSION';
const payload = {};
const requireShim = jasmine.createSpy('requireShim')
.and.returnValue(Promise.resolve(payload));
const importShim = jasmine.createSpy('importShim')
.and.returnValue(Promise.reject(error));
const loader = new Loader({requireShim, importShim});
loader.alwaysImport = true;
const result = await loader.load('./spec.jsx');
expect(result).toBe(payload);
expect(requireShim).toHaveBeenCalled();
expect(importShim).toHaveBeenCalled();
});
});
it('imports non-local modules', async function() {
const payload = {default: {}};
const requireShim = jasmine.createSpy('requireShim');
const importShim = jasmine.createSpy('importShim')
.and.returnValue(Promise.resolve(payload));
const loader = new Loader({requireShim, importShim});
loader.alwaysImport = true;
const result = await loader.load('some-module');
expect(result).toBe(payload.default);
expect(requireShim).not.toHaveBeenCalled();
expect(importShim).toHaveBeenCalledWith('some-module');
});
it('uses require to load JSON files', async function() {
const requireShim = jasmine.createSpy('requireShim')
.and.returnValue(Promise.resolve());
const importShim = jasmine.createSpy('importShim');
const loader = new Loader({requireShim, importShim});
loader.alwaysImport = true;
await expectAsync(loader.load('./jasmine.json')).toBeResolved();
expect(requireShim).toHaveBeenCalledWith('./jasmine.json');
expect(importShim).not.toHaveBeenCalled();
});
});
describe('With alwaysImport: false', function() {
describe('When the path ends in .mjs', function () {
esModuleSharedExamples('mjs', false);
});
it('uses require to load JSON files', async function() {
const requireShim = jasmine.createSpy('requireShim')
.and.returnValue(Promise.resolve());
const importShim = jasmine.createSpy('importShim');
const loader = new Loader({requireShim, importShim});
loader.alwaysImport = false;
await expectAsync(loader.load('./jasmine.json')).toBeResolved();
expect(requireShim).toHaveBeenCalledWith('./jasmine.json');
expect(importShim).not.toHaveBeenCalled();
});
describe('When the path does not end in .mjs', function () {
it('loads the file as a commonjs module', async function () {
const requireShim = jasmine.createSpy('requireShim')
.and.returnValue(Promise.resolve());
const importShim = jasmine.createSpy('importShim');
const loader = new Loader({requireShim, importShim});
loader.alwaysImport = false;
await expectAsync(loader.load('./foo/bar/baz')).toBeResolved();
expect(requireShim).toHaveBeenCalledWith('./foo/bar/baz');
expect(importShim).not.toHaveBeenCalled();
});
it('propagates the error when import fails', async function () {
const underlyingError = new Error('nope');
const requireShim = jasmine.createSpy('requireShim')
.and.throwError(underlyingError);
const importShim = jasmine.createSpy('importShim');
const loader = new Loader({requireShim, importShim});
loader.alwaysImport = false;
await expectAsync(loader.load('foo')).toBeRejectedWith(underlyingError);
});
});
});
});
});
function esModuleSharedExamples(extension, alwaysImport) {
async function testBasicEsModuleLoading(separator) {
const requireShim = jasmine.createSpy('requireShim');
let resolve;
const importPromise = new Promise(function (res) {
resolve = res;
});
const importShim = jasmine.createSpy('importShim')
.and.returnValue(importPromise);
const resolvePath = jasmine.createSpy('resolvePath')
.and.returnValue('/the/path/to/the/module');
const loader = new Loader({requireShim, importShim, resolvePath});
loader.alwaysImport = alwaysImport;
const requestedPath = ['foo', 'bar', `baz.${extension}`].join(separator);
const loaderPromise = loader.load(requestedPath);
expect(requireShim).not.toHaveBeenCalled();
expect(resolvePath).toHaveBeenCalledWith(requestedPath);
expect(importShim).toHaveBeenCalledWith('file:///the/path/to/the/module');
await expectAsync(loaderPromise).toBePending();
resolve({});
await expectAsync(loaderPromise).toBeResolved();
}
it('loads the file as an es module', async function () {
await testBasicEsModuleLoading(path.sep);
});
it('supports /-separated paths', async function() {
await testBasicEsModuleLoading('/');
});
it("adds the filename to ES module syntax errors", async function() {
const underlyingError = new SyntaxError('some details but no filename, not even in the stack trace');
const loader = new Loader({importShim: () => Promise.reject(underlyingError)});
await expectAsync(loader.load(`foo.${extension}`, alwaysImport)).toBeRejectedWithError(
`While loading foo.${extension}: SyntaxError: some details but no filename, not even in the stack trace`
);
});
it('does not modify errors that are not SyntaxError instances', async function() {
const underlyingError = new Error('nope');
const loader = new Loader({importShim: () => Promise.reject(underlyingError)});
await expectAsync(loader.load(`foo.${extension}`, alwaysImport)).toBeRejectedWith(underlyingError);
});
it('does not modify SyntaxErrors that mention the imported filename as a Unix-style path', async function() {
const underlyingError = new SyntaxError('nope');
underlyingError.stack = `/the/absolute/path/to/foo.${extension}:1\n` +
'\n' +
'\n' +
'\n' +
'maybe some more stack\n';
const loader = new Loader({importShim: () => Promise.reject(underlyingError)});
await expectAsync(loader.load(`path/to/foo.${extension}`, alwaysImport))
.toBeRejectedWith(underlyingError);
});
it('does not modify SyntaxErrors that mention the imported filename as a Unix-style file URL', async function() {
const underlyingError = new SyntaxError('nope');
underlyingError.stack += `\n at async file:///the/absolute/path/to/foo.${extension}:1:1`;
const loader = new Loader({importShim: () => Promise.reject(underlyingError)});
await expectAsync(loader.load(`path/to/foo.${extension}`, alwaysImport))
.toBeRejectedWith(underlyingError);
});
it('does not modify SyntaxErrors that mention the imported filename as a Windows-style path', async function() {
const underlyingError = new SyntaxError('nope');
underlyingError.stack = `c:\\the\\absolute\\path\\to\\foo.${extension}:1\n` +
'\n' +
'\n' +
'\n' +
'maybe some more stack\n';
const loader = new Loader({importShim: () => Promise.reject(underlyingError)});
await expectAsync(loader.load(`path/to/foo.${extension}`, alwaysImport))
.toBeRejectedWith(underlyingError);
});
it('does not modify SyntaxErrors that mention the imported filename as a Windows-style file URL', async function() {
const underlyingError = new SyntaxError('nope');
underlyingError.stack += `\n at async file:///c:/the/absolute/path/to/foo.${extension}:1:1`;
const loader = new Loader({importShim: () => Promise.reject(underlyingError)});
await expectAsync(loader.load(`path/to/foo.${extension}`, alwaysImport))
.toBeRejectedWith(underlyingError);
});
it('does not modify SyntaxErrors when the stack trace starts with any Unix-style path', async function() {
const underlyingError = new SyntaxError('nope');
underlyingError.stack = '/some/path/to/a/file.js:1\n\n\n\n' + underlyingError.stack;
const loader = new Loader({importShim: () => Promise.reject(underlyingError)});
await expectAsync(loader.load(`path/to/some/other/file.${extension}`, alwaysImport))
.toBeRejectedWith(underlyingError);
});
it('does not modify SyntaxErrors when the stack trace starts with any Windows-style path', async function() {
const underlyingError = new SyntaxError('nope');
underlyingError.stack = 'c:\\some\\path\\to\\a\\file.js:1\n\n\n\n' + underlyingError.stack;
const loader = new Loader({importShim: () => Promise.reject(underlyingError)});
await expectAsync(loader.load(`path/to/some/other/file.${extension}`, alwaysImport))
.toBeRejectedWith(underlyingError);
});
}
jasmine-npm-4.5.0/spec/npm_package_spec.js 0000664 0000000 0000000 00000003100 14327321345 0020503 0 ustar 00root root 0000000 0000000 const path = require('path');
const temp = require('temp').track();
const fs = require('fs');
describe('npm package', function() {
beforeAll(function() {
const shell = require('shelljs'),
pack = shell.exec('npm pack', { silent: true });
this.tarball = pack.stdout.split('\n')[0];
this.tmpDir = temp.mkdirSync(); // automatically deleted on exit
const untar = shell.exec('tar -xzf ' + this.tarball + ' -C ' + this.tmpDir, {
silent: true
});
expect(untar.code).toBe(0);
});
beforeEach(function() {
jasmine.addMatchers({
toExistInPath: function() {
return {
compare: function(actual, expected) {
const fullPath = path.resolve(expected, actual);
return {
pass: fs.existsSync(fullPath)
};
}
};
}
});
});
afterAll(function() {
fs.unlinkSync(this.tarball);
});
it('has a jasmine script', function() {
expect('package/bin/jasmine.js').toExistInPath(this.tmpDir);
});
it('has a jasmine module', function() {
expect('package/lib/jasmine.js').toExistInPath(this.tmpDir);
});
it('contains only the expected root entries', function() {
const files = fs.readdirSync(this.tmpDir);
expect(files).toEqual(['package']);
});
it('contains only the expected entries in the package dir', function() {
const files = fs.readdirSync(path.resolve(this.tmpDir, 'package'));
files.sort();
expect(files).toEqual([
'MIT.LICENSE',
'README.md',
'bin',
'lib',
'package.json',
]);
});
});
jasmine-npm-4.5.0/spec/reporters/ 0000775 0000000 0000000 00000000000 14327321345 0016721 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/reporters/console_reporter_spec.js 0000664 0000000 0000000 00000046702 14327321345 0023666 0 ustar 00root root 0000000 0000000 const ConsoleReporter = require('../../lib/reporters/console_reporter');
describe("ConsoleReporter", function() {
beforeEach(function() {
this.out = (function() {
let output = "";
return {
print: function(str) {
output += str;
},
getOutput: function() {
return output;
},
clear: function() {
output = "";
}
};
}());
});
it("reports that the suite has started to the console", function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print
});
reporter.jasmineStarted();
expect(this.out.getOutput()).toEqual("Started\n");
});
describe("When order information is passed to jasmineStarted", function() {
it("reports the seed number when randomized", function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print
});
reporter.jasmineStarted({
order: {
random: true,
seed: '12345'
}
});
expect(this.out.getOutput()).toMatch(/Randomized with seed 12345/);
});
it("does not report order info when not randomized", function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print
});
reporter.jasmineStarted({
order: {
random: false
}
});
expect(this.out.getOutput()).not.toMatch(/Randomized/);
});
});
it("setOptions should not override existing options if set multiple times", function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print,
showColors: false
});
reporter.jasmineStarted();
expect(this.out.getOutput()).toEqual("Started\n");
// clean up this.out.output
this.out.clear();
expect(this.out.getOutput()).toEqual("");
// set options that does not include print, should still print with this.out.print
reporter.setOptions({
showColors: true
});
reporter.jasmineStarted();
expect(this.out.getOutput()).toEqual("Started\n");
});
it("reports a passing spec as a dot", function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print
});
reporter.specDone({status: "passed"});
expect(this.out.getOutput()).toEqual(".");
});
it("does not report a disabled spec", function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print
});
reporter.specDone({status: "disabled"});
expect(this.out.getOutput()).toEqual("");
});
it("reports a failing spec as an 'F'", function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print
});
reporter.specDone({status: "failed"});
expect(this.out.getOutput()).toEqual("F");
});
it("reports a pending spec as a '*'", function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print
});
reporter.specDone({status: "pending"});
expect(this.out.getOutput()).toEqual("*");
});
it("alerts user if there are no specs", function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print
});
reporter.jasmineStarted();
this.out.clear();
reporter.jasmineDone({});
expect(this.out.getOutput()).toMatch(/No specs found/);
});
it("reports the seed number when running in random order", function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print
});
reporter.jasmineDone({
order: {
random: true,
seed: '12345'
}
});
expect(this.out.getOutput()).toMatch(/Randomized with seed 12345 \(jasmine --random=true --seed=12345\)/);
});
it("allows the seed reproduction command to be overridden", function() {
const reporter = new ConsoleReporter("jasmine-some-other-tool");
reporter.setOptions({
print: this.out.print,
randomSeedReproductionCmd: function(seed) {
return `jasmine-some-other-tool --randomSeed=${seed}`;
}
});
reporter.jasmineDone({
order: {
random: true,
seed: '12345'
}
});
expect(this.out.getOutput()).toMatch(/Randomized with seed 12345 \(jasmine-some-other-tool --randomSeed=12345\)/);
});
it("reports a summary when done (singular spec and time)", function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print,
});
reporter.jasmineStarted();
reporter.specDone({status: "passed"});
this.out.clear();
reporter.jasmineDone({ totalTime: 1000 });
expect(this.out.getOutput()).not.toMatch(/Ran 1/);
expect(this.out.getOutput()).toMatch(/1 spec, 0 failures/);
expect(this.out.getOutput()).not.toMatch(/0 pending specs/);
expect(this.out.getOutput()).toMatch("Finished in 1 second\n");
});
it("reports a summary when done (pluralized specs and seconds)", function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print,
});
reporter.jasmineStarted();
reporter.specDone({status: "passed"});
reporter.specDone({status: "pending"});
reporter.specDone({
status: "failed",
description: "with a failing spec",
fullName: "A suite with a failing spec",
failedExpectations: [
{
passed: false,
message: "Expected true to be false.",
expected: false,
actual: true,
stack: ''
}
],
passedExpectations: []
});
this.out.clear();
reporter.jasmineDone({ totalTime: 100 });
expect(this.out.getOutput()).toMatch(/3 specs, 1 failure, 1 pending spec/);
expect(this.out.getOutput()).toMatch("Finished in 0.1 seconds\n");
});
it('counts failures that are reported in the jasmineDone event', function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print,
});
reporter.jasmineStarted();
reporter.specDone({
status: "failed",
description: "with a failing spec",
fullName: "with a failing spec",
failedExpectations: [
{
message: "Expected true to be false.",
}
],
passedExpectations: []
});
this.out.clear();
reporter.jasmineDone({
totalTime: 100,
failedExpectations: [
{
message: "Expected true to be false.",
},
{
message: "Expected true to be false.",
}
],
});
expect(this.out.getOutput()).toMatch(/1 spec, 3 failures/);
});
it("reports a summary when done that indicates the number of specs run (when it's less that the full number of specs)", function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print,
});
reporter.jasmineStarted();
reporter.specDone({status: "passed"});
reporter.specDone({status: "disabled"});
this.out.clear();
reporter.jasmineDone({ totalTime: 1000 });
expect(this.out.getOutput()).toMatch(/Ran 1 of 2 specs/);
expect(this.out.getOutput()).toMatch(/1 spec, 0 failures/);
});
it("reports a summary when done that includes the failed spec number before the full name of a failing spec", function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print,
});
reporter.jasmineStarted();
reporter.specDone({status: "passed"});
reporter.specDone({
status: "failed",
description: "with a failing spec",
fullName: "A suite with a failing spec",
failedExpectations: [
{
passed: false,
message: "Expected true to be false.",
expected: false,
actual: true,
stack: ''
}
],
passedExpectations: []
});
this.out.clear();
reporter.jasmineDone({});
expect(this.out.getOutput()).toMatch(/1\) A suite with a failing spec/);
});
it("reports a summary when done that includes stack traces for a failing suite", function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print
});
reporter.jasmineStarted();
reporter.specDone({status: "passed"});
reporter.specDone({
status: "failed",
description: "with a failing spec",
fullName: "A suite with a failing spec",
failedExpectations: [
{
passed: false,
message: "Expected true to be false.",
expected: false,
actual: true,
stack: 'line 1\nline 2'
}
],
passedExpectations: []
});
this.out.clear();
reporter.jasmineDone({});
expect(this.out.getOutput()).toMatch(/true to be false/);
expect(this.out.getOutput()).toMatch(/line 1/);
expect(this.out.getOutput()).toMatch(/line 2/);
});
it("reports a summary when done in case that stack is somehow undefined", function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print,
});
reporter.jasmineStarted();
reporter.specDone({status: "passed"});
reporter.specDone({
status: "failed",
description: "with a failing spec",
fullName: "A suite with a failing spec",
failedExpectations: [
{
passed: false,
message: "Expected true to be false.",
expected: false,
actual: true,
stack: undefined
}
],
passedExpectations: []
});
this.out.clear();
reporter.jasmineDone({});
expect(this.out.getOutput()).toMatch(/true to be false/);
});
it("reports a summary when done that includes custom filtered stack traces for a failing suite", function() {
const stackLine = 'custom line of stack';
const customStackFilter = function(stack) {
return stackLine;
};
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print,
stackFilter: customStackFilter
});
reporter.jasmineStarted();
reporter.specDone({status: "passed"});
reporter.specDone({
status: "failed",
description: "with a failing spec",
fullName: "A suite with a failing spec",
failedExpectations: [
{
passed: false,
message: "Expected true to be false.",
expected: false,
actual: true,
stack: 'the original stack trace'
}
],
passedExpectations: []
});
this.out.clear();
reporter.jasmineDone({});
expect(this.out.getOutput()).toMatch(/true to be false/);
expect(this.out.getOutput()).toMatch(stackLine);
});
describe('When the overall status is passed', function() {
it('includes pending specs in the summary even if alwaysListPendingSpecs is false', function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print,
alwaysListPendingSpecs: false
});
reporter.jasmineStarted();
reporter.specDone({
status: "pending",
description: "with a pending spec",
fullName: "A suite with a pending spec",
pendingReason: "It's not ready yet!"
});
this.out.clear();
reporter.jasmineDone({overallStatus: 'passed'});
expect(this.out.getOutput()).toContain("Pending:");
expect(this.out.getOutput()).toContain("A suite with a pending spec");
expect(this.out.getOutput()).toContain("It's not ready yet!");
});
});
describe('When the overall status is failed', function() {
it('includes pending specs in the summary when alwaysListPendingSpecs is true', function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print,
alwaysListPendingSpecs: true
});
reporter.jasmineStarted();
reporter.specDone({
status: "pending",
description: "with a pending spec",
fullName: "A suite with a pending spec",
pendingReason: "It's not ready yet!"
});
this.out.clear();
reporter.jasmineDone({overallStatus: 'failed'});
expect(this.out.getOutput()).toContain("Pending:");
expect(this.out.getOutput()).toContain("A suite with a pending spec");
expect(this.out.getOutput()).toContain("It's not ready yet!");
});
it('omits pending specs in the summary when alwaysListPendingSpecs is false', function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print,
alwaysListPendingSpecs: false
});
reporter.jasmineStarted();
reporter.specDone({
status: "pending",
description: "with a pending spec",
fullName: "A suite with a pending spec",
pendingReason: "It's not ready yet!"
});
this.out.clear();
reporter.jasmineDone({overallStatus: 'failed'});
expect(this.out.getOutput()).not.toContain("Pending:");
expect(this.out.getOutput()).not.toContain("A suite with a pending spec");
expect(this.out.getOutput()).not.toContain("It's not ready yet!");
});
it('includes pending specs in the summary when alwaysListPendingSpecs is unspecified', function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print,
});
reporter.jasmineStarted();
reporter.specDone({
status: "pending",
description: "with a pending spec",
fullName: "A suite with a pending spec",
pendingReason: "It's not ready yet!"
});
this.out.clear();
reporter.jasmineDone({overallStatus: 'failed'});
expect(this.out.getOutput()).toContain("Pending:");
expect(this.out.getOutput()).toContain("A suite with a pending spec");
expect(this.out.getOutput()).toContain("It's not ready yet!");
});
});
it("reports a summary when done that includes the reason for an incomplete suite", function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print,
});
reporter.jasmineStarted();
this.out.clear();
reporter.jasmineDone({
overallStatus: "incomplete",
incompleteReason: "not all bars were frobnicated"
});
expect(this.out.getOutput()).toContain("Incomplete: not all bars were frobnicated");
});
it("reports a summary when done that shows info for a failed spec with no expectations", function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print,
});
reporter.jasmineStarted();
reporter.specDone({status: "passed"});
reporter.specDone({
status: "failed",
description: "with a failing spec",
fullName: "A suite with a failing spec that has no expectations",
failedExpectations: [],
passedExpectations: []
});
this.out.clear();
reporter.jasmineDone({});
expect(this.out.getOutput()).toContain("Spec has no expectations");
});
it('reports a summary without "no expectations" message for a spec having failed expectations', function () {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print,
});
reporter.jasmineStarted();
reporter.specDone({
status: "failed",
description: "with a failing spec",
fullName: "A suite with a failing spec that has a failing expectation",
failedExpectations: [{
passed: false,
message: "Expected true to be false.",
expected: false,
actual: true,
stack: undefined
}],
passedExpectations: []
});
this.out.clear();
reporter.jasmineDone({});
expect(this.out.getOutput()).not.toContain("Spec has no expectations");
});
it('reports a summary with debug log info for a failed spec with debug logs', function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print,
});
reporter.jasmineStarted();
reporter.specDone({
status: "failed",
description: "with a failing spec",
fullName: "A suite with a failing spec that has a trace",
failedExpectations: [],
passedExpectations: [],
debugLogs: [
{timestamp: 1, message: 'msg 1'},
{timestamp: 100, message: 'msg 2'},
]
});
reporter.jasmineDone({});
expect(this.out.getOutput()).toContain(' Debug logs:\n 1ms: msg 1\n 100ms: msg 2');
});
it('reports a summary without a "no expectations" message for a spec having passed expectations', function () {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print,
});
reporter.jasmineStarted();
reporter.specDone({
status: "passed",
description: "with a passed spec",
fullName: "A suite with a passed spec",
passedExpectations: [{
passed: true,
message: "Expected true to be true.",
expected: true,
actual: true
}]
});
reporter.specDone({
status: "failed",
description: "with a failing spec",
fullName: "A suite with a failing spec that has both passed and failing expectations",
failedExpectations: [],
passedExpectations: [{
passed: true,
message: "Expected true to be true.",
expected: true,
actual: true
}]
});
this.out.clear();
reporter.jasmineDone({});
expect(this.out.getOutput()).not.toContain("Spec has no expectations");
});
it("displays all afterAll exceptions", function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print,
showColors: false
});
reporter.suiteDone({
fullName: 'suite 1',
failedExpectations: [{ message: 'After All Exception' }]
});
reporter.suiteDone({
fullName: 'suite 2',
failedExpectations: [{ message: 'Some Other Exception' }]
});
reporter.jasmineDone({ failedExpectations: [{ message: 'Global Exception' }] });
expect(this.out.getOutput()).toMatch(/Suite error: suite 1\s+Message:\s+After All Exception/);
expect(this.out.getOutput()).toMatch(/Suite error: suite 2\s+Message:\s+Some Other Exception/);
expect(this.out.getOutput()).toMatch(/Suite error: top suite\s+Message:\s+Global Exception/);
});
describe("with color", function() {
it("reports that the suite has started to the console", function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print,
showColors: true
});
reporter.jasmineStarted();
expect(this.out.getOutput()).toEqual("Started\n");
});
it("reports a passing spec as a dot", function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print,
showColors: true
});
reporter.specDone({status: "passed"});
expect(this.out.getOutput()).toEqual("\x1B[32m.\x1B[0m");
});
it("does not report a disabled spec", function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print,
showColors: true
});
reporter.specDone({status: 'disabled'});
expect(this.out.getOutput()).toEqual("");
});
it("reports a failing spec as an 'F'", function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print,
showColors: true
});
reporter.specDone({status: 'failed'});
expect(this.out.getOutput()).toEqual("\x1B[31mF\x1B[0m");
});
});
});
jasmine-npm-4.5.0/spec/support/ 0000775 0000000 0000000 00000000000 14327321345 0016410 5 ustar 00root root 0000000 0000000 jasmine-npm-4.5.0/spec/support/jasmine.json 0000664 0000000 0000000 00000000337 14327321345 0020734 0 ustar 00root root 0000000 0000000 {
"spec_dir": "spec",
"spec_files": [
"*[sS]pec.js",
"reporters/**/*[sS]pec.js",
"filters/**/*[sS]pec.js"
],
"helpers": [
"helpers/**/*.js"
],
"random": true,
"alwaysListPendingSpecs": false
}