pax_global_header00006660000000000000000000000064141671613200014513gustar00rootroot0000000000000052 comment=00a19c0f7bb23d211889f4aba3d5f04cdb722c61 jasmine-npm-4.0.2/000077500000000000000000000000001416716132000137345ustar00rootroot00000000000000jasmine-npm-4.0.2/.circleci/000077500000000000000000000000001416716132000155675ustar00rootroot00000000000000jasmine-npm-4.0.2/.circleci/config.yml000066400000000000000000000032371416716132000175640ustar00rootroot00000000000000# Run tests against supported Node versions version: 2.1 orbs: node: circleci/node@3.0.0 executors: node16: docker: - image: cimg/node:16.1.0 working_directory: ~/workspace node14_latest: docker: - image: circleci/node:14 working_directory: ~/workspace node14_8: docker: - image: circleci/node:14.8 working_directory: ~/workspace node14_7: docker: - image: circleci/node:14.7 working_directory: ~/workspace node12_latest: docker: - image: circleci/node:12 working_directory: ~/workspace node12_17: docker: - image: circleci/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 workflows: version: 2 push: &push_workflow jobs: - test: matrix: parameters: executor: - 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 cron: <<: *push_workflow triggers: - schedule: # Times are UTC. cron: "0 10 * * *" filters: branches: only: - main jasmine-npm-4.0.2/.editorconfig000066400000000000000000000001731416716132000164120ustar00rootroot00000000000000[*] charset = utf-8 end_of_line = lf insert_final_newline = true [*.{js, json, yml}] indent_style = space indent_size = 2 jasmine-npm-4.0.2/.eslintignore000066400000000000000000000003631416716132000164410ustar00rootroot00000000000000spec/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.0.2/.gitignore000066400000000000000000000002351416716132000157240ustar00rootroot00000000000000.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.0.2/Gruntfile.js000066400000000000000000000016601416716132000162340ustar00rootroot00000000000000module.exports = function(grunt) { var pkg = require("./package.json"); global.jasmineVersion = pkg.version; var versionString = 'v' + pkg.version; grunt.initConfig({ pkg: pkg }); var shell = require('shelljs'); function runCommands(commands, done) { var command = commands.shift(); if (command) { shell.exec(command, function(exitCode) { if (exitCode !== 0) { grunt.fail.fatal("Command `" + command + "` failed", exitCode); done(); } else { runCommands(commands, done); } }); } else { done(); } } grunt.registerTask('release', 'Create tag ' + versionString + ' and push jasmine-' + pkg.version + ' to NPM', function() { var done = this.async(), commands = ['git tag ' + versionString, 'git push origin main --tags', 'npm publish']; runCommands(commands, done); }); }; jasmine-npm-4.0.2/MIT.LICENSE000066400000000000000000000020451416716132000153720ustar00rootroot00000000000000Copyright (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.0.2/README.md000066400000000000000000000035501416716132000152160ustar00rootroot00000000000000[![Build Status](https://circleci.com/gh/jasmine/jasmine-npm.svg?style=shield)](https://circleci.com/gh/jasmine/jasmine-npm) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fjasmine%2Fjasmine-npm.svg?type=shield)](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 12.x where x >=17, Node 14, and Node 16. ## 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 [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fjasmine%2Fjasmine-npm.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fjasmine%2Fjasmine-npm?ref=badge_large) jasmine-npm-4.0.2/bin/000077500000000000000000000000001416716132000145045ustar00rootroot00000000000000jasmine-npm-4.0.2/bin/jasmine.js000077500000000000000000000006711416716132000164770ustar00rootroot00000000000000#!/usr/bin/env node const path = require('path'); const Command = require('../lib/command'); const Jasmine = require('../lib/jasmine'); const jasmine = new Jasmine({ projectBaseDir: path.resolve() }); const examplesDir = path.join(path.dirname(require.resolve('jasmine-core')), 'jasmine-core', 'example', 'node_example'); const command = new Command(path.resolve(), examplesDir, console.log); command.run(jasmine, process.argv.slice(2)); jasmine-npm-4.0.2/lib/000077500000000000000000000000001416716132000145025ustar00rootroot00000000000000jasmine-npm-4.0.2/lib/command.js000066400000000000000000000217111416716132000164600ustar00rootroot00000000000000const 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, print) { this.projectBaseDir = projectBaseDir; this.specDir = path.join(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); if (env.unknownOptions.length > 0) { process.exitCode = 1; print('Unknown options: ' + env.unknownOptions.join(', ')); print(''); help({print: print}); } else { await runJasmine(jasmine, env, print); } } }; } function isFileArg(arg) { return arg.indexOf('--') !== 0 && !isEnvironmentVariable(arg); } function parseOptions(argv) { let files = [], helpers = [], requires = [], unknownOptions = [], color = process.stdout.isTTY || false, reporter, configPath, filter, failFast, random, seed; for (let i in argv) { const arg = argv[i]; 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(arg); } else if (!isEnvironmentVariable(arg)) { unknownOptions.push(arg); } } return { color: color, configPath: configPath, filter: filter, failFast: failFast, helpers: helpers, requires: requires, reporter: reporter, files: files, random: random, seed: seed, unknownOptions: unknownOptions }; } async function runJasmine(jasmine, env, print) { await jasmine.loadConfigFile(env.configPath || process.env.JASMINE_CONFIG_PATH); if (env.failFast !== undefined) { jasmine.env.configure({ stopSpecOnExpectationFailure: env.failFast, stopOnSpecFailure: env.failFast }); } if (env.seed !== undefined) { jasmine.seed(env.seed); } if (env.random !== undefined) { jasmine.randomizeTests(env.random); } if (env.helpers !== undefined && env.helpers.length) { jasmine.addHelperFiles(env.helpers); } if (env.requires !== undefined && env.requires.length) { jasmine.addRequires(env.requires); } if (env.reporter !== undefined) { await registerReporter(env.reporter, jasmine); } jasmine.showColors(env.color); try { await jasmine.execute(env.files, env.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; } }); } jasmine-npm-4.0.2/lib/examples/000077500000000000000000000000001416716132000163205ustar00rootroot00000000000000jasmine-npm-4.0.2/lib/examples/jasmine.json000066400000000000000000000003051416716132000206370ustar00rootroot00000000000000{ "spec_dir": "spec", "spec_files": [ "**/*[sS]pec.?(m)js" ], "helpers": [ "helpers/**/*.?(m)js" ], "env": { "stopSpecOnExpectationFailure": false, "random": true } } jasmine-npm-4.0.2/lib/exit_handler.js000066400000000000000000000003541416716132000175100ustar00rootroot00000000000000class ExitHandler { constructor(onExit) { this._onExit = onExit; } install() { process.on('exit', this._onExit); } uninstall() { process.removeListener('exit', this._onExit); } } module.exports = ExitHandler; jasmine-npm-4.0.2/lib/filters/000077500000000000000000000000001416716132000161525ustar00rootroot00000000000000jasmine-npm-4.0.2/lib/filters/console_spec_filter.js000066400000000000000000000004261416716132000225330ustar00rootroot00000000000000module.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.0.2/lib/jasmine.js000066400000000000000000000365301416716132000164750ustar00rootroot00000000000000const 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'); module.exports = Jasmine; module.exports.ConsoleReporter = require('./reporters/console_reporter'); /** * 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(); */ function Jasmine(options) { options = options || {}; this.loader = options.loader || new Loader(); const jasmineCore = options.jasmineCore || require('jasmine-core'); if (options.globals === false) { this.jasmine = jasmineCore.noGlobals().jasmine; } else { this.jasmine = jasmineCore.boot(jasmineCore); } this.projectBaseDir = options.projectBaseDir || 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.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 */ Jasmine.prototype.randomizeTests = function(value) { this.env.configure({random: value}); }; /** * Sets the random seed. * @function * @name Jasmine#seed * @param {number} seed The random seed */ Jasmine.prototype.seed = function(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 */ Jasmine.prototype.showColors = function(value) { this.showingColors = 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. */ Jasmine.prototype.addSpecFile = function(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. */ Jasmine.prototype.addHelperFile = function(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 */ Jasmine.prototype.addReporter = function(reporter) { this.env.addReporter(reporter); this.reportersCount++; }; /** * Clears all registered reporters. * @function * @name Jasmine#clearReporters */ Jasmine.prototype.clearReporters = function() { 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 */ Jasmine.prototype.provideFallbackReporter = function(reporter) { this.env.provideFallbackReporter(reporter); }; /** * Configures the default reporter that is installed if no other reporter is * specified. * @param {ConsoleReporterOptions} options */ Jasmine.prototype.configureDefaultReporter = function(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 */ Jasmine.prototype.addMatchers = function(matchers) { this.env.addMatchers(matchers); }; Jasmine.prototype.loadSpecs = async function() { await this._loadFiles(this.specFiles); }; Jasmine.prototype.loadHelpers = async function() { await this._loadFiles(this.helperFiles); }; Jasmine.prototype._loadFiles = async function(files) { for (const file of files) { await this.loader.load(file); } }; Jasmine.prototype.loadRequires = async function() { 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 */ Jasmine.prototype.loadConfigFile = async function(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; } } } } }; Jasmine.prototype.loadSpecificConfigFile_ = async function(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 */ Jasmine.prototype.loadConfig = function(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; /** * 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 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); } }; /** * 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'); Jasmine.prototype.addRequires = function(requires) { const jasmineRunner = this; requires.forEach(function(r) { jasmineRunner.requires.push(r); }); }; function addFiles(kind) { return function (files) { 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); }); }); }; } /** * 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 */ Jasmine.prototype.stopSpecOnExpectationFailure = function(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 */ Jasmine.prototype.stopOnSpecFailure = function(value) { this.env.configure({stopOnSpecFailure: value}); }; Jasmine.prototype.flushOutput = async function() { // 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. */ Jasmine.prototype.execute = async function(files, filterString) { await this.loadRequires(); await this.loadHelpers(); if (!this.defaultReporterConfigured) { this.configureDefaultReporter({ showColors: this.showingColors }); } 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; }; 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; } } jasmine-npm-4.0.2/lib/loader.js000066400000000000000000000153121416716132000163100ustar00rootroot00000000000000const path = require('path'); module.exports = Loader; function Loader(options) { options = options || {}; this.require_ = options.requireShim || requireShim; this.import_ = options.importShim || importShim; this.resolvePath_ = options.resolvePath || path.resolve.bind(path); this.alwaysImport = true; } Loader.prototype.load = function(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'); } jasmine-npm-4.0.2/lib/reporters/000077500000000000000000000000001416716132000165275ustar00rootroot00000000000000jasmine-npm-4.0.2/lib/reporters/console_reporter.js000066400000000000000000000165761416716132000224700ustar00rootroot00000000000000module.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 = [], 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; } }; 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 (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.0.2/package.json000066400000000000000000000026511416716132000162260ustar00rootroot00000000000000{ "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.0.2", "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.0.0" }, "bin": "./bin/jasmine.js", "main": "./lib/jasmine.js", "devDependencies": { "eslint": "^6.8.0", "grunt": "^1.0.4", "grunt-cli": "^1.3.2", "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.0.2/release_notes/000077500000000000000000000000001416716132000165645ustar00rootroot00000000000000jasmine-npm-4.0.2/release_notes/2.1.0.md000066400000000000000000000017301416716132000175450ustar00rootroot00000000000000# 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.0.2/release_notes/2.1.1.md000066400000000000000000000011121416716132000175400ustar00rootroot00000000000000# 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.0.2/release_notes/2.2.0.md000066400000000000000000000007561416716132000175550ustar00rootroot00000000000000# 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.0.2/release_notes/2.2.1.md000066400000000000000000000004341416716132000175470ustar00rootroot00000000000000# 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.0.2/release_notes/2.3.0.md000066400000000000000000000040641416716132000175520ustar00rootroot00000000000000# 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.0.2/release_notes/2.3.1.md000066400000000000000000000006311416716132000175470ustar00rootroot00000000000000# 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.0.2/release_notes/2.3.2.md000066400000000000000000000010721416716132000175500ustar00rootroot00000000000000# 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.0.2/release_notes/2.4.0.md000066400000000000000000000006341416716132000175520ustar00rootroot00000000000000# 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.0.2/release_notes/2.4.1.md000066400000000000000000000004211416716132000175450ustar00rootroot00000000000000# 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.0.2/release_notes/2.5.0.md000066400000000000000000000030511416716132000175470ustar00rootroot00000000000000# 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.0.2/release_notes/2.5.1.md000066400000000000000000000014351416716132000175540ustar00rootroot00000000000000# 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.0.2/release_notes/2.5.2.md000066400000000000000000000006221416716132000175520ustar00rootroot00000000000000# 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.0.2/release_notes/2.5.3.md000066400000000000000000000011421416716132000175510ustar00rootroot00000000000000# 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.0.2/release_notes/2.6.0.md000066400000000000000000000013141416716132000175500ustar00rootroot00000000000000# 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.0.2/release_notes/2.7.0.md000066400000000000000000000012721416716132000175540ustar00rootroot00000000000000# 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.0.2/release_notes/2.8.0.md000066400000000000000000000005071416716132000175550ustar00rootroot00000000000000# 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.0.2/release_notes/2.9.0.md000066400000000000000000000005071416716132000175560ustar00rootroot00000000000000# 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.0.2/release_notes/2.99.md000066400000000000000000000005561416716132000175150ustar00rootroot00000000000000# 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.0.2/release_notes/3.0.md000066400000000000000000000021041416716132000174030ustar00rootroot00000000000000# 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.0.2/release_notes/3.1.0.md000066400000000000000000000010301416716132000175370ustar00rootroot00000000000000# 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.0.2/release_notes/3.10.0.md000066400000000000000000000032111416716132000176220ustar00rootroot00000000000000# 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.0.2/release_notes/3.2.0.md000066400000000000000000000017121416716132000175470ustar00rootroot00000000000000# 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.0.2/release_notes/3.3.0.md000066400000000000000000000013441416716132000175510ustar00rootroot00000000000000# 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.0.2/release_notes/3.3.1.md000066400000000000000000000011161416716132000175470ustar00rootroot00000000000000# 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.0.2/release_notes/3.4.0.md000066400000000000000000000014151416716132000175510ustar00rootroot00000000000000# 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.0.2/release_notes/3.5.0.md000066400000000000000000000006271416716132000175560ustar00rootroot00000000000000# 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.0.2/release_notes/3.6.0.md000066400000000000000000000016531416716132000175570ustar00rootroot00000000000000# 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.0.2/release_notes/3.6.1.md000066400000000000000000000004421416716132000175530ustar00rootroot00000000000000# 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.0.2/release_notes/3.6.2.md000066400000000000000000000020771416716132000175620ustar00rootroot00000000000000# 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.0.2/release_notes/3.6.3.md000066400000000000000000000013621416716132000175570ustar00rootroot00000000000000# 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.0.2/release_notes/3.6.4.md000066400000000000000000000010501416716132000175520ustar00rootroot00000000000000# 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.0.2/release_notes/3.7.0.md000066400000000000000000000003511416716132000175520ustar00rootroot00000000000000# 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.0.2/release_notes/3.8.0.md000066400000000000000000000033331416716132000175560ustar00rootroot00000000000000# 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.0.2/release_notes/3.9.0.md000066400000000000000000000016051416716132000175570ustar00rootroot00000000000000# 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.0.2/release_notes/3.99.0.md000066400000000000000000000005261416716132000176510ustar00rootroot00000000000000# 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.0.2/release_notes/4.0.0.md000066400000000000000000000103641416716132000175510ustar00rootroot00000000000000# 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`. If you have specs or source files with such extensions, 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.0.2/release_notes/4.0.1.md000066400000000000000000000006311416716132000175460ustar00rootroot00000000000000# 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.0.2/release_notes/4.0.2.md000066400000000000000000000007741416716132000175570ustar00rootroot00000000000000# 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.0.2/spec/000077500000000000000000000000001416716132000146665ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/command_spec.js000066400000000000000000000373511416716132000176650ustar00rootroot00000000000000const 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, this.out.print); this.fakeJasmine = jasmine.createSpyObj('jasmine', ['loadConfigFile', 'addHelperFiles', '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.addHelperFiles).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.addHelperFiles).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.addHelperFiles).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'); }); }); }); // 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.0.2/spec/filters/000077500000000000000000000000001416716132000163365ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/filters/console_spec_filter_spec.js000066400000000000000000000015601416716132000237310ustar00rootroot00000000000000const 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.0.2/spec/fixtures/000077500000000000000000000000001416716132000165375ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/badReporter.js000066400000000000000000000000001416716132000213340ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/cjs-load-exception/000077500000000000000000000000001416716132000222275ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/cjs-load-exception/jasmine.json000066400000000000000000000001261416716132000245470ustar00rootroot00000000000000{ "spec_dir": ".", "spec_files": [ "throws_on_load.js" ], "helpers": [] } jasmine-npm-4.0.2/spec/fixtures/cjs-load-exception/throws_on_load.js000066400000000000000000000000311416716132000256000ustar00rootroot00000000000000throw new Error("nope"); jasmine-npm-4.0.2/spec/fixtures/cjs-syntax-error/000077500000000000000000000000001416716132000217715ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/cjs-syntax-error/jasmine.json000066400000000000000000000001241416716132000243070ustar00rootroot00000000000000{ "spec_dir": ".", "spec_files": [ "syntax_error.js" ], "helpers": [] } jasmine-npm-4.0.2/spec/fixtures/cjs-syntax-error/syntax_error.js000066400000000000000000000000121416716132000250570ustar00rootroot00000000000000function( jasmine-npm-4.0.2/spec/fixtures/customReporter.js000066400000000000000000000000471416716132000221330ustar00rootroot00000000000000module.exports = function Report() {}; jasmine-npm-4.0.2/spec/fixtures/customReporter.mjs000066400000000000000000000002751416716132000223130ustar00rootroot00000000000000export default function Reporter() {} Reporter.prototype.jasmineDone = function() { console.log('customReporter.mjs jasmineDone'); }; Reporter.prototype.isCustomReporterDotMjs = true;jasmine-npm-4.0.2/spec/fixtures/defaultProgrammaticFail.js000066400000000000000000000002101416716132000236540ustar00rootroot00000000000000const Jasmine = require('../..'); const jasmine = new Jasmine(); it('fails', function() { expect(1).toBe(2); }); jasmine.execute(); jasmine-npm-4.0.2/spec/fixtures/dontExitOnCompletion.js000066400000000000000000000003621416716132000232230ustar00rootroot00000000000000const 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.0.2/spec/fixtures/env-config/000077500000000000000000000000001416716132000205725ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/env-config/aSpec.js000066400000000000000000000001441416716132000221620ustar00rootroot00000000000000for (let i = 1; i <= 5; i++) { it('spec 1', function() { console.log('in spec ' + i); }); } jasmine-npm-4.0.2/spec/fixtures/env-config/jasmine.json000066400000000000000000000001301416716132000231050ustar00rootroot00000000000000{ "spec_dir": ".", "spec_files": ["aSpec.js"], "env": { "random": false } } jasmine-npm-4.0.2/spec/fixtures/esm-importing-commonjs-syntax-error/000077500000000000000000000000001416716132000256275ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/esm-importing-commonjs-syntax-error/intermediate.js000066400000000000000000000000331416716132000306330ustar00rootroot00000000000000require('./syntax_error'); jasmine-npm-4.0.2/spec/fixtures/esm-importing-commonjs-syntax-error/jasmine.json000066400000000000000000000001151416716132000301450ustar00rootroot00000000000000{ "spec_dir": ".", "spec_files": [ "spec.mjs" ], "helpers": [] } jasmine-npm-4.0.2/spec/fixtures/esm-importing-commonjs-syntax-error/spec.mjs000066400000000000000000000000431416716132000272710ustar00rootroot00000000000000await import('./intermediate.js'); jasmine-npm-4.0.2/spec/fixtures/esm-importing-commonjs-syntax-error/syntax_error.js000066400000000000000000000000021416716132000307140ustar00rootroot00000000000000{ jasmine-npm-4.0.2/spec/fixtures/esm-indirect-error/000077500000000000000000000000001416716132000222515ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/esm-indirect-error/jasmine.json000066400000000000000000000001151416716132000245670ustar00rootroot00000000000000{ "spec_dir": ".", "spec_files": [ "spec.mjs" ], "helpers": [] } jasmine-npm-4.0.2/spec/fixtures/esm-indirect-error/spec.mjs000066400000000000000000000000601416716132000237120ustar00rootroot00000000000000import './throws.mjs'; it('a spec', () => {}); jasmine-npm-4.0.2/spec/fixtures/esm-indirect-error/throws.mjs000066400000000000000000000000311416716132000243040ustar00rootroot00000000000000throw new Error('nope'); jasmine-npm-4.0.2/spec/fixtures/esm-load-exception/000077500000000000000000000000001416716132000222345ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/esm-load-exception/jasmine.json000066400000000000000000000001271416716132000245550ustar00rootroot00000000000000{ "spec_dir": ".", "spec_files": [ "throws_on_load.mjs" ], "helpers": [] } jasmine-npm-4.0.2/spec/fixtures/esm-load-exception/throws_on_load.mjs000066400000000000000000000000311416716132000257620ustar00rootroot00000000000000throw new Error("nope"); jasmine-npm-4.0.2/spec/fixtures/esm-reporter-packagejson/000077500000000000000000000000001416716132000234465ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/esm-reporter-packagejson/customReporter.js000066400000000000000000000002121416716132000270340ustar00rootroot00000000000000export default function Reporter() {} Reporter.prototype.jasmineDone = function() { console.log('customReporter.js jasmineDone'); }; jasmine-npm-4.0.2/spec/fixtures/esm-reporter-packagejson/jasmine.json000066400000000000000000000001051416716132000257630ustar00rootroot00000000000000{ "spec_dir": ".", "spec_files": [ ], "jsLoader": "import" } jasmine-npm-4.0.2/spec/fixtures/esm-reporter-packagejson/package.json000066400000000000000000000000271416716132000257330ustar00rootroot00000000000000{ "type": "module" } jasmine-npm-4.0.2/spec/fixtures/esm-syntax-error/000077500000000000000000000000001416716132000217765ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/esm-syntax-error/jasmine.json000066400000000000000000000001251416716132000243150ustar00rootroot00000000000000{ "spec_dir": ".", "spec_files": [ "syntax_error.mjs" ], "helpers": [] } jasmine-npm-4.0.2/spec/fixtures/esm-syntax-error/syntax_error.mjs000066400000000000000000000000121416716132000252410ustar00rootroot00000000000000function( jasmine-npm-4.0.2/spec/fixtures/esm/000077500000000000000000000000001416716132000173235ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/esm/commonjs_helper.js000066400000000000000000000001001416716132000230340ustar00rootroot00000000000000console.log('commonjs_helper'); require('./commonjs_sentinel'); jasmine-npm-4.0.2/spec/fixtures/esm/commonjs_sentinel.js000066400000000000000000000001011416716132000233770ustar00rootroot00000000000000// An empty module that we can require, to see if require works. jasmine-npm-4.0.2/spec/fixtures/esm/commonjs_spec.js000066400000000000000000000002271416716132000225210ustar00rootroot00000000000000describe('A spec file ending in .js', function() { it('is required as a commonjs module', function() { require('./commonjs_sentinel'); }); }); jasmine-npm-4.0.2/spec/fixtures/esm/esm_helper.mjs000066400000000000000000000000701416716132000221560ustar00rootroot00000000000000import './esm_sentinel.mjs'; console.log('esm_helper'); jasmine-npm-4.0.2/spec/fixtures/esm/esm_sentinel.mjs000066400000000000000000000001201416716132000225140ustar00rootroot00000000000000// An empty module that will fail if loaded via require(), due to its extension jasmine-npm-4.0.2/spec/fixtures/esm/esm_spec.mjs000066400000000000000000000005441416716132000216370ustar00rootroot00000000000000describe('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.0.2/spec/fixtures/esm/jasmine.mjs000066400000000000000000000004261416716132000214660ustar00rootroot00000000000000const 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.0.2/spec/fixtures/esm/name_reporter.js000066400000000000000000000002671416716132000225300ustar00rootroot00000000000000console.log('name_reporter'); beforeAll(function() { jasmine.getEnv().addReporter({ specStarted: function (event) { console.log('Spec:', event.fullName); } }); }); jasmine-npm-4.0.2/spec/fixtures/example/000077500000000000000000000000001416716132000201725ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/example/lib/000077500000000000000000000000001416716132000207405ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/example/lib/jasmine_examples/000077500000000000000000000000001416716132000242645ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/example/lib/jasmine_examples/Bar.js000066400000000000000000000000001416716132000253140ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/example/lib/jasmine_examples/Foo.js000066400000000000000000000000001416716132000253330ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/example/spec/000077500000000000000000000000001416716132000211245ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/example/spec/helpers/000077500000000000000000000000001416716132000225665ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/example/spec/helpers/jasmine_examples/000077500000000000000000000000001416716132000261125ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/example/spec/helpers/jasmine_examples/SpecHelper.js000066400000000000000000000000001416716132000304700ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/example/spec/jasmine_examples/000077500000000000000000000000001416716132000244505ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/example/spec/jasmine_examples/FooSpec.js000066400000000000000000000000001416716132000263320ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/import-jsx/000077500000000000000000000000001416716132000206535ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/import-jsx/jasmine.json000066400000000000000000000001151416716132000231710ustar00rootroot00000000000000{ "spec_dir": ".", "spec_files": [ "spec.jsx" ], "helpers": [] } jasmine-npm-4.0.2/spec/fixtures/import-jsx/spec.jsx000066400000000000000000000000411416716132000223260ustar00rootroot00000000000000it('is a spec', function() { }); jasmine-npm-4.0.2/spec/fixtures/jasmine_spec/000077500000000000000000000000001416716132000211775ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/jasmine_spec/c.js000066400000000000000000000000001416716132000217450ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/jasmine_spec/d.js000066400000000000000000000000001416716132000217460ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/jasmine_spec/e.js000066400000000000000000000000001416716132000217470ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/jasmine_spec/f.js000066400000000000000000000000001416716132000217500ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/js-loader-default/000077500000000000000000000000001416716132000220415ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/js-loader-default/anEsModule.js000066400000000000000000000000471416716132000244340ustar00rootroot00000000000000export function foo() { return 42; } jasmine-npm-4.0.2/spec/fixtures/js-loader-default/anEsModuleSpec.js000066400000000000000000000002141416716132000252430ustar00rootroot00000000000000import {foo} from './anEsModule.js'; describe('foo', function() { it('returns 42', function() { expect(foo()).toEqual(42); }); }); jasmine-npm-4.0.2/spec/fixtures/js-loader-default/anEsRequire.js000066400000000000000000000000321416716132000246150ustar00rootroot00000000000000import './anEsModule.js'; jasmine-npm-4.0.2/spec/fixtures/js-loader-default/jasmine.json000066400000000000000000000001641416716132000243630ustar00rootroot00000000000000{ "spec_dir": ".", "spec_files": ["anEsModuleSpec.js"], "requires": ["../js-loader-default/anEsRequire.js"] } jasmine-npm-4.0.2/spec/fixtures/js-loader-default/package.json000066400000000000000000000000271416716132000243260ustar00rootroot00000000000000{ "type": "module" } jasmine-npm-4.0.2/spec/fixtures/js-loader-import/000077500000000000000000000000001416716132000217275ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/js-loader-import/anEsModule.js000066400000000000000000000000471416716132000243220ustar00rootroot00000000000000export function foo() { return 42; } jasmine-npm-4.0.2/spec/fixtures/js-loader-import/anEsModuleSpec.js000066400000000000000000000002141416716132000251310ustar00rootroot00000000000000import {foo} from './anEsModule.js'; describe('foo', function() { it('returns 42', function() { expect(foo()).toEqual(42); }); }); jasmine-npm-4.0.2/spec/fixtures/js-loader-import/anEsRequire.js000066400000000000000000000000321416716132000245030ustar00rootroot00000000000000import './anEsModule.js'; jasmine-npm-4.0.2/spec/fixtures/js-loader-import/anotherEsModuleSpec.js000066400000000000000000000002141416716132000261730ustar00rootroot00000000000000import {foo} from './anEsModule.js'; describe('foo', function() { it('returns 42', function() { expect(foo()).toEqual(42); }); }); jasmine-npm-4.0.2/spec/fixtures/js-loader-import/jasmine.json000066400000000000000000000002131416716132000242440ustar00rootroot00000000000000{ "spec_dir": ".", "spec_files": ["anEsModuleSpec.js"], "requires": ["../js-loader-import/anEsRequire.js"], "jsLoader": "import" } jasmine-npm-4.0.2/spec/fixtures/js-loader-import/package.json000066400000000000000000000000271416716132000242140ustar00rootroot00000000000000{ "type": "module" } jasmine-npm-4.0.2/spec/fixtures/js-loader-require/000077500000000000000000000000001416716132000220715ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/js-loader-require/aRequire.js000066400000000000000000000001251416716132000242020ustar00rootroot00000000000000if (!module.parent) { throw new Error('aRequire.js was loaded as an ES module'); } jasmine-npm-4.0.2/spec/fixtures/js-loader-require/aSpec.js000066400000000000000000000002311416716132000234560ustar00rootroot00000000000000describe('a file with js extension', function() { it('was loaded as a CommonJS module', function() { expect(module.parent).toBeTruthy(); }); }); jasmine-npm-4.0.2/spec/fixtures/js-loader-require/jasmine.json000066400000000000000000000002171416716132000244120ustar00rootroot00000000000000{ "spec_dir": ".", "spec_files": ["aSpec.js"], "requires": ["../spec/fixtures/js-loader-require/aRequire.js"], "jsLoader": "require" } jasmine-npm-4.0.2/spec/fixtures/no-globals/000077500000000000000000000000001416716132000205745ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/no-globals/aSpec.js000066400000000000000000000002371416716132000221670ustar00rootroot00000000000000const {it, expect} = require('jasmine-core').noGlobals(); it('can use equality testers defined in a different file', function() { expect(1).toEqual(2); }); jasmine-npm-4.0.2/spec/fixtures/no-globals/runner.js000066400000000000000000000012721416716132000224450ustar00rootroot00000000000000const 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.0.2/spec/fixtures/prematureExit.js000066400000000000000000000002071416716132000217320ustar00rootroot00000000000000const Jasmine = require('../..'); const jasmine = new Jasmine(); it('a spec', function() { process.exit(0); }); jasmine.execute(); jasmine-npm-4.0.2/spec/fixtures/promiseFailure.js000066400000000000000000000004321416716132000220620ustar00rootroot00000000000000const 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.0.2/spec/fixtures/promiseIncomplete.js000066400000000000000000000004601416716132000225730ustar00rootroot00000000000000const 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.0.2/spec/fixtures/promiseSuccess.js000066400000000000000000000004041416716132000221020ustar00rootroot00000000000000const 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.0.2/spec/fixtures/require_tester.js000066400000000000000000000000761416716132000221420ustar00rootroot00000000000000global.require_tester_was_loaded = true; module.exports = {}; jasmine-npm-4.0.2/spec/fixtures/sample_project/000077500000000000000000000000001416716132000215465ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/sample_project/spec/000077500000000000000000000000001416716132000225005ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/sample_project/spec/fixture_spec.js000066400000000000000000000000001416716132000255240ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/sample_project/spec/helper.js000066400000000000000000000000001416716132000243030ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/sample_project/spec/other_fixture_spec.js000066400000000000000000000000001416716132000267250ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/sample_project/spec/support/000077500000000000000000000000001416716132000242145ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/fixtures/sample_project/spec/support/jasmine.json000066400000000000000000000001061416716132000265320ustar00rootroot00000000000000{ "spec_dir": "spec", "spec_files": [ "fixture_spec.js" ] } jasmine-npm-4.0.2/spec/fixtures/sample_project/spec/support/jasmine_alternate.cjs000066400000000000000000000002731416716132000304040ustar00rootroot00000000000000module.exports = { "spec_dir": "spec", "spec_files": [ "fixture_spec.js", "**/*spec.js" ], "helpers": [ "helper.js" ], "requires": [ "ts-node/register" ] }; jasmine-npm-4.0.2/spec/fixtures/sample_project/spec/support/jasmine_alternate.json000066400000000000000000000002511416716132000305720ustar00rootroot00000000000000{ "spec_dir": "spec", "spec_files": [ "fixture_spec.js", "**/*spec.js" ], "helpers": [ "helper.js" ], "requires": [ "ts-node/register" ] } jasmine-npm-4.0.2/spec/fixtures/sample_project/spec/support/jasmine_alternate.mjs000066400000000000000000000003571416716132000304210ustar00rootroot00000000000000const config = { "spec_dir": "spec", "spec_files": [ "fixture_spec.js", "**/*spec.js" ], "helpers": [ "helper.js" ], "requires": [ "ts-node/register" ] }; export default config; jasmine-npm-4.0.2/spec/fixtures/topLevelAwaitSentinel.mjs000066400000000000000000000000311416716132000235260ustar00rootroot00000000000000await Promise.resolve(); jasmine-npm-4.0.2/spec/integration_spec.js000066400000000000000000000177241416716132000205740ustar00rootroot00000000000000const 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.0.2/spec/jasmine_spec.js000066400000000000000000000552261416716132000176760ustar00rootroot00000000000000const 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'); 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(); }); }); }); 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}); expect(this.testJasmine.loadSpecs).toHaveBeenCalled(); expect(this.testJasmine.env.execute).toHaveBeenCalled(); }); it('configures the default console reporter with the right color settings', async function() { spyOn(this.testJasmine, 'configureDefaultReporter'); spyOn(this.testJasmine, 'loadSpecs'); this.testJasmine.showColors(false); await this.execute(); expect(this.testJasmine.configureDefaultReporter).toHaveBeenCalledWith({showColors: 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'})); }); }); }); }); jasmine-npm-4.0.2/spec/loader_spec.js000066400000000000000000000224021416716132000175040ustar00rootroot00000000000000const 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.0.2/spec/npm_package_spec.js000066400000000000000000000031001416716132000204750ustar00rootroot00000000000000const 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.0.2/spec/reporters/000077500000000000000000000000001416716132000167135ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/reporters/console_reporter_spec.js000066400000000000000000000416301416716132000236530ustar00rootroot00000000000000const 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); }); it("reports a summary when done that includes which specs are pending and their reasons", 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({}); 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.0.2/spec/support/000077500000000000000000000000001416716132000164025ustar00rootroot00000000000000jasmine-npm-4.0.2/spec/support/jasmine.json000066400000000000000000000002741416716132000207260ustar00rootroot00000000000000{ "spec_dir": "spec", "spec_files": [ "*[sS]pec.js", "reporters/**/*[sS]pec.js", "filters/**/*[sS]pec.js" ], "helpers": [ "helpers/**/*.js" ], "random": true }