Simple JavaScript testing framework for browsers and node.js

Overview

Build Status Open Source Helpers FOSSA Status

A JavaScript Testing Framework

Jasmine is a Behavior Driven Development testing framework for JavaScript. It does not rely on browsers, DOM, or any JavaScript framework. Thus it's suited for websites, Node.js projects, or anywhere that JavaScript can run.

Documentation & guides live here: http://jasmine.github.io For a quick start guide of Jasmine, see the beginning of http://jasmine.github.io/edge/introduction.html.

Upgrading from Jasmine 2.x? Check out the 3.0 release notes for a list of what's new (including breaking changes).

Contributing

Please read the contributors' guide.

Installation

For the Jasmine NPM module:
https://github.com/jasmine/jasmine-npm.

For the Jasmine Ruby Gem:
https://github.com/jasmine/jasmine-gem.

For the Jasmine Python Egg:
https://github.com/jasmine/jasmine-py.

For the Jasmine headless browser gulp plugin:
https://github.com/jasmine/gulp-jasmine-browser.

To install Jasmine standalone on your local box (where {#.#.#} below is substituted by the release number downloaded):

  • Download the standalone distribution for your desired release from the releases page.
  • Create a Jasmine directory in your project. - mkdir my-project/jasmine
  • Move the dist to your project directory. - mv jasmine/dist/jasmine-standalone-{#.#.#}.zip my-project/jasmine
  • Change directory. - cd my-project/jasmine
  • Unzip the dist. - unzip jasmine-standalone-{#.#.#}.zip

Add the following to your HTML file:

<link rel="shortcut icon" type="image/png" href="lib/jasmine-{#.#.#}/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="lib/jasmine-{#.#.#}/jasmine.css">

<script type="text/javascript" src="lib/jasmine-{#.#.#}/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-{#.#.#}/jasmine-html.js"></script>
<script type="text/javascript" src="lib/jasmine-{#.#.#}/boot.js"></script>

Supported environments

Jasmine tests itself across many browsers (Safari, Chrome, Firefox, Microsoft Edge, and Internet Explorer) as well as nodejs.

Environment Supported versions
Node 10, 12, 14
Safari 8-14
Chrome Evergreen
Firefox Evergreen, 68, 78
Edge Evergreen
Internet Explorer 10, 11

For evergreen browsers, each version of Jasmine is tested against the version of the browser that is available to us at the time of release. Other browsers, as well as older & newer versions of some supported browsers, are likely to work. However, Jasmine isn't tested against them and they aren't actively supported.

Support

Maintainers

Maintainers Emeritus

Copyright (c) 2008-2018 Pivotal Labs. This software is licensed under the MIT License.

License

FOSSA Status

Comments
  • Karma - Disconnected, because no message in 10000 ms.

    Karma - Disconnected, because no message in 10000 ms.

    So after I did a rm -r node_modules;npm install today, my jasmine tests (ran via karma) started failing with a Disconnected, because no message in 10000 ms.

    After half a day debugging... it all came down to jasmine-core causing the issue. After you guys upped your version to 2.6.0 I started getting the Disconnected, because no message in 10000 ms. message).

    So I did a binary commit search until I found the commit that broke my test build. This is the commit https://github.com/jasmine/jasmine/commit/2f01f642496139db1cb807247ffe32968af9db3c, which is part of the 2.6.0 release

    Before this commit, my karma tests run just fine.

    For now my solution was to go back [email protected] in my package.json without any carret or tilde.

    Seems some people in here https://github.com/karma-runner/karma-phantomjs-launcher/issues/126 are having issues the last days, not sure, but it might be related to the commit mentioned:

    • What version are you using? These are the dependencies in my package.json:
    "devDependencies": {
        "async": "^1.5.1",
        "beeper": "^1.1.0",
        "del": "^1.2.0",
        "eslint": "^2.13.1",
        "eslint-plugin-angular": "^0.11.0",
        "eslint-plugin-jasmine": "^1.8.0",
        "eslint-plugin-lodash": "^1.9.0",
        "glob": "^6.0.3",
        "gulp": "^3.9.0",
        "gulp-angular-templatecache": "^1.7.0",
        "gulp-autoprefixer": "^2.3.1",
        "gulp-clean-css": "^2.0.7",
        "gulp-concat": "^2.6.0",
        "gulp-eslint": "^2.1.0",
        "gulp-filter": "^3.0.0",
        "gulp-help": "^1.6.0",
        "gulp-htmlhint": "^0.3.1",
        "gulp-if": "^1.2.5",
        "gulp-imagemin": "^2.3.0",
        "gulp-inject": "^1.5.0",
        "gulp-json-editor": "^2.2.1",
        "gulp-load-plugins": "^1.0.0-rc.1",
        "gulp-minify-html": "^1.0.4",
        "gulp-ng-annotate": "^1.1.0",
        "gulp-notify": "^2.2.0",
        "gulp-plumber": "^1.0.1",
        "gulp-print": "^1.1.0",
        "gulp-rename": "^1.2.2",
        "gulp-replace": "^0.5.3",
        "gulp-rev": "^5.1.0",
        "gulp-rev-replace": "^0.4.2",
        "gulp-sass": "^2.1.0",
        "gulp-shell": "^0.4.2",
        "gulp-size": "^2.1.0",
        "gulp-sourcemaps": "^1.5.2",
        "gulp-symlink": "^2.1.2",
        "gulp-uglify": "^1.2.0",
        "gulp-uncss": "^1.0.2",
        "gulp-useref": "^1.2.0",
        "gulp-util": "^3.0.6",
        "gulp-watch": "^4.3.5",
        "gulp-zip": "^3.0.2",
        "jasmine-ajax": "^3.2.0",
        "jasmine-core": "^2.4.1",
        "karma": "^1.3.0",
        "karma-beep-reporter": "^0.1.4",
        "karma-chrome-launcher": "^2.0.0",
        "karma-coffee-preprocessor": "^1.0.1",
        "karma-coverage": "^1.1.1",
        "karma-firefox-launcher": "^1.0.0",
        "karma-growl-reporter": "^1.0.0",
        "karma-html2js-preprocessor": "^1.1.0",
        "karma-jasmine": "^1.0.2",
        "karma-junit-reporter": "^1.1.0",
        "karma-ng-html2js-preprocessor": "^1.0.0",
        "karma-phantomjs-launcher": "^1.0.2",
        "karma-requirejs": "^1.1.0",
        "karma-script-launcher": "^1.0.0",
        "karma-spec-reporter": "0.0.26",
        "lazypipe": "^1.0.1",
        "lodash": "^3.10.1",
        "map-stream": "0.0.6",
        "node-notifier": "^4.2.3",
        "phantomjs": "^2.1.7",
        "require-dir": "^0.3.0",
        "requirejs": "^2.1.18",
        "run-sequence": "^1.1.2",
        "vinyl-paths": "^1.0.0",
        "yargs": "^3.15.0",
        "bower": "^1.8.0"
      },
    
    • What environment are you running Jasmine in (node, browser, etc)? Running karma with [email protected] on a OSX Sierra machine, but it is also happening in a unix machine
    • How are you running Jasmine (standalone, npm, karma, etc)? karma

    Thanks!!!

    opened by cafesanu 77
  • Bail on first failure

    Bail on first failure

    opened by hurrymaplelad 68
  • Add ddescribe, iit for exclusive suites,specs

    Add ddescribe, iit for exclusive suites,specs

    When any ddescribe is registered, only specs withing these exclusive suites will be run

    describe('normal', function() {
      ddescribe('exclusive', function() {
        // all specs here will be run
      });
    
      // nothing here will run
      it('should not run', function() {});
    });
    

    When any iit is registered, only these exclusive specs will be run (precedence over ddescribe)

    it('should not run', function() {});
    iit('should run', function() {});
    it('should not run 2', function() {});
    iit('should run as well', function() {});
    

    We've been using this feature for quit a while during development of AngularJS.

    It's part of Jasmine - JsTD adapter, I think it was originally an idea of @IgorMinar.

    I really miss this feature when using jasmine-node or when using SlimJim.

    I think, it really should be part of the core, so I did implement it.

    feature request 
    opened by vojtajina 60
  • Adding because descriptions to expect failures

    Adding because descriptions to expect failures

    In the past and elsewhere there has been discussion of adding .because property to expect chain for clearer failure classification. The proposed syntax was:

    expect(true).toEqual(false).because('yes it is')
    

    Is there a possibility that this feature could be introduced, a reason it has not been introduced and has the team ever estimated how much work the feature would be to implement? In select cases this could greatly improve the speed of resolving causes for breaks, especially if you're trying to find the cause of failures from a CI log etc.

    opened by aleksihakli 59
  • toEqual should list differences instead of pretty printing objects

    toEqual should list differences instead of pretty printing objects

    Consider this simple example (jsfiddle):

    var actual = { x: 1, y: { z: 2 } };
    var expected = { x: 1, y: { z: 3 }};
    expect(actual).toEqual(expected);
    

    This outputs: Expected { x : 1, y : { z : 2 } } to equal { x : 1, y : { z : 3 } }.

    In other words it pretty prints both objects.

    Now imagine we are in real world where objects are quite complex and toEqual quickly becomes useless.

    I would expect output like:

    Expected no differences but found 1:
    1. Expected y.z = 2 to equal 3
    

    i.e. list all differences with paths.

    opened by mwisnicki 48
  • Spy Restore()

    Spy Restore()

    This idea comes from sinon.js where you can setup a spy then later on restore it back to the original method in the case you no longer need or want the spy.

    This works well when having a spy setup that is used in most cases but in the rare case it isn't, it's more useful to set one up then for the special case remove it.

    Note: this does not clean up after itself for removeAllSpies but doesn't have any bad side effects.

    jasmine.Spy.prototype.restore = function() {
      this.baseObj[this.methodName] = this.originalValue;
    };
    
    describe('Spies', function() {
      it('should restore spied function', function() {
        var originalFunctionWasCalled = false;
        var TestCase = {
          someFunction: function() {
            originalFunctionWasCalled = true;
            return 'return value from original function';
          };
        };
        this.spyOn(TestClass, 'someFunction');
    
        TestClass.someFunction.restore();
        expect(TestClass.someFunction()).toEqual('return value from original function');
        expect(originalFunctionWasCalled).toEqual(true);
      });
    });
    
    waiting 
    opened by vizjerai 44
  • Get currently executed test name in beforeEach

    Get currently executed test name in beforeEach

    TLDR; Is there a way to get the currently executed test case (its description derived from describe / it) in a beforeEach block?

    What for?

    Assuming I have a test runner that performs some sort of visual job on the screen (e.g. drawing SVG elements).

    I provide each test case with a container to draw on and want the result to be inspectable by a user. In addition, I would like to add a caption to each of the tests, so that the user can easier keep track of which drawing result belongs to which test execution.

    opened by nikku 38
  • Fail with error & stack trace in asynchronous code

    Fail with error & stack trace in asynchronous code

    When an error is thrown from asynchronous code, Jasmine currently has no way of knowing that it happened, skipping subsequent stages (e.g. "it" following error in "beforeEach") and reporting a trace.

    As a workaround, I have written helper code to catch and record the error from a function execution so that it can be re-thrown from an "afterEach" block. This solution at least gives a failure and a stack trace, but still leaves a lot to be desired.

    For my partial workaround, see the "asyncStep" and "getCaptureAsyncError" functions in https://github.com/stevecj/headway/blob/master/spec/support/userContextExt.js . To see how those are used, see https://github.com/stevecj/headway/blob/master/spec/indexedDbAdapterSpec.js .

    feature request has Tracker story 
    opened by stevecj 38
  • How to use async/await with Jasmine?

    How to use async/await with Jasmine?

    Hi, how can I use async/await with Jasmine? Is this supported somehow? I'd like to do

    it('should run test', async function() {
        browser.get('https://duckduckgo.com/');
        $('#search_form_input_homepage').sendKeys('jasmine');
        $('#search_button_homepage').click();
    
        let title = await browser.getTitle();
        expect(title).toBe('foo');
      });
    

    Instead of

      it('should run test', function(done) {
        browser.get('https://duckduckgo.com/');
        $('#search_form_input_homepage').sendKeys('jasmine');
        $('#search_button_homepage').click();
    
        browser.getTitle().then(function(title) {
          expect(title).toBe('foo');
          done();
        });
      });
    

    Do I need to do that manually like here?

    opened by donaldpipowitch 30
  • 2.6 upgrade from 2.5.2 generates errors

    2.6 upgrade from 2.5.2 generates errors

    Jasmine 2.5.2 -> 2.6.0

    I am running my tests using Karma and PhantomJS and until yesterday everything was running smoothly but since then my Jenkins tests have been failing. After downgrading to jasmine 2.5.2 explicitly everything went back to normal.

    > karma start ./config/karma.conf.js
    
    PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
      TypeError: undefined is not a constructor (evaluating 'global.process.listeners('uncaughtException')')
      at node_modules/jasmine-core/lib/jasmine-core/jasmine.js:2180
    PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
      TypeError: undefined is not a constructor (evaluating 'global.process.listeners('uncaughtException')')
      at node_modules/jasmine-core/lib/jasmine-core/jasmine.js:2180
    
    PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 0 of 44 ERROR (0.002 secs / 0 secs)
    
    npm ERR! Test failed.  See above for more details.
    

    I am fine with 2.5.2, but I am just putting it here in case someone else really needs 2.6 and needs this fixed

    opened by samudurand 28
  • Tests breaks after upgrading jasmine-core from 2.99.0 to 3.1.0

    Tests breaks after upgrading jasmine-core from 2.99.0 to 3.1.0

    Expected Behavior

    I'm running Angular 5 test cases with karma/jasmine. The test should succeed but fails. Can't really tell which package is responsible for the actual bug. But he bug occurred after upgrading jasmine-core from 2.99.0 -> 3.1.0. If you think this bug is related to Karma or any other package, please tell so and feel free to close it.

    Current Behavior

    I have an Angular 5 project running karma/jasmine. Unfortunately the tests stopped working after upgrading from 2.99.0 to 3.1.0 with this ambiguous error.

    Chrome 64.0.3282 (Windows 10.0.0) ERROR
      {
        "message": "An error was thrown in afterAll\n[object ErrorEvent]",
        "str": "An error was thrown in afterAll\n[object ErrorEvent]"
      }
    Chrome 64.0.3282 (Windows 10.0.0): Executed 1 of 1 ERROR (0 secs / 0 secs)
    Chrome 64.0.3282 (Windows 10.0.0) ERROR
      {
        "message": "An error was thrown in afterAll\n[object ErrorEvent]",
        "str": "An error was thrown in afterAll\n[object ErrorEvent]"
    Chrome 64.0.3282 (Windows 10.0.0): Executed 1 of 1 ERROR (0.187 secs / 0 secs)
    

    Possible Solution

    None. I'm happy to help debugging the issue. But my knowledge of karma/jasmine is to limited to do without assistance.

    Suite that reproduces the behavior (for bugs)

    import { async, TestBed } from '@angular/core/testing';
    import { StartComponent } from './start.component';
    describe('StartComponent', () => {
        beforeEach(async(() => {
            TestBed.configureTestingModule({
                declarations: [
                    StartComponent
                ],
            }).compileComponents();
        }));
        it('should create the app', async(() => {
            const fixture = TestBed.createComponent(StartComponent);
            const app = fixture.debugElement.componentInstance;
            expect(app).toBeTruthy();
        }));
    });
    

    Your Environment

    • Version used: 3.1.0
    • Environment name and version (e.g. Chrome 39, node.js 5.4): Chrome 64, Node 8.9.4,
    • Operating System and version (desktop or mobile): Dekstop
    {
    "devDependencies": {
        "@angular/cli": "6.0.0-beta.4",
        "@angular/compiler-cli": "6.0.0-beta.6",
        "@types/jasmine": "2.8.6",
        "@types/jasminewd2": "2.0.3",
        "@types/node": "8.0.19",
        "@types/webpack": "3.8.8",
        "awesome-typescript-loader": "3.5.0",
        "css-loader": "0.28.10",
        "extract-text-webpack-plugin": "4.0.0-beta.0",
        "html-loader": "0.5.5",
        "html-webpack-plugin": "^3.0.4",
        "husky": "0.14.3",
        "jasmine-core": "^2.99.0",
        "jasmine-spec-reporter": "4.2.1",
        "karma": "2.0.0",
        "karma-chrome-launcher": "2.2.0",
        "karma-coverage-istanbul-reporter": "1.4.1",
        "karma-jasmine": "1.1.1",
        "karma-jasmine-html-reporter": "0.2.2",
        "less": "3.0.1",
        "less-loader": "4.0.6",
        "postcss": "6.0.19",
        "postcss-cssnext": "3.1.0",
        "postcss-easy-import": "3.0.0",
        "postcss-load-plugins": "2.3.0",
        "postcss-loader": "2.1.1",
        "protractor": "^5.3.0",
        "puppeteer": "1.1.1",
        "serve": "6.5.1",
        "style-loader": "0.20.2",
        "to-string-loader": "1.1.5",
        "ts-node": "5.0.1",
        "tslint": "5.9.1",
        "tslint-config-standard": "7.0.0",
        "tslint-eslint-rules": "5.1.0",
        "typescript": "2.6.2",
        "uglifyjs-webpack-plugin": "1.2.2",
        "webpack": "4.1.0",
        "webpack-cli": "^2.0.10",
        "webpack-dev-server": "3.1.0",
        "write-file-webpack-plugin": "4.2.0"
      },
      "dependencies": {
        "@angular/animations": "6.0.0-beta.6",
        "@angular/common": "6.0.0-beta.6",
        "@angular/compiler": "6.0.0-beta.6",
        "@angular/core": "6.0.0-beta.6",
        "@angular/forms": "6.0.0-beta.6",
        "@angular/http": "6.0.0-beta.6",
        "@angular/language-service": "6.0.0-beta.6",
        "@angular/platform-browser": "6.0.0-beta.6",
        "@angular/platform-browser-dynamic": "6.0.0-beta.6",
        "@angular/router": "5.2.7",
        "angular": "1.6.9",
        "core-js": "2.5.3",
        "rxjs": "5.5.6",
        "zone.js": "0.8.20"
      }
    }
    
    Karma 
    opened by JonWallsten 27
  • How to unit test a Custom Matcher failure message in jasmine v4?

    How to unit test a Custom Matcher failure message in jasmine v4?

    Suite that reproduces the behavior

    Say we have a customer matcher like the one below (this is a toy example in TypeScript, not our real code).

    function toBeCoolFactory(util: jasmine.MatchersUtil): jasmine.CustomMatcher {
      return {
        compare: (actual: { cool?: boolean }) => {
    
          if (actual.cool === undefined || actual.cool === false) {
            return { pass: false, message: `Expected '${util.pp(actual)}' to be cool` };
          }
    
          return { pass: true };
        }
      };
    }
    

    In Jasmine v2 / v3 we would unit test the matcher by creating the custom matcher using the static jasmine.matchersUtil (which we learned how to do from this old issue https://github.com/jasmine/jasmine/issues/1024).

    describe(`test if cool matcher`, () => {
      it(`should return a error message saying the object is not cool`, () => {
        const matcher = toBeCoolFactory(jasmine.matchersUtil);
        const { pass, message } = matcher.compare({});
    
        expect(pass).toBe(false);
        expect(message).toBe(`Expected 'Object({  })' to be cool`);
      });
    });
    

    Current Behavior

    Running this test in jasmine v3.99.0 we get the following deprecation warning

    DEPRECATION: jasmine.matchersUtil is deprecated and will be removed in a future release. Use the instance passed to the matcher factory or the asymmetric equality tester's `asymmetricMatch` method instead. See <https://jasmine.github.io/tutorials/upgrading_to_Jasmine_4.0#static-utils> for details. (in spec: JasmineMatchers test if cool matcher should return a error message saying the object is not cool)
        at <Jasmine>
        at UserContext.<anonymous> (\JasmineMatchers.test.js)
        at <Jasmine>
    Note: This message will be shown only once. Set the verboseDeprecations config property to true to see every occurrence.
    

    Running in jasmine v4.4.0 results in a runtime error

    Failures:
    1) JasmineMatchers test if cool matcher should return a error message saying the object is not cool
      Message:
        TypeError: Cannot read properties of undefined (reading 'pp')
    

    Context

    With the static jasmine.matchersUtil.pp function being deprecated I am looking for guidance on how to write tests for custom matchers where we want to assert on the actual error message like above. We have 100s of such tests for a variety of custom matchers in my company.

    I looked at how the core matchers tests were written (for example toEqualSpec.js) and they appear to be creating a new MatchersUtil which the documentation says not to do here.

    Class: MatchersUtil MatchersUtil Utilities for use in implementing matchers. Note: Do not construct this directly. Jasmine will construct one and pass it to matchers and asymmetric equality testers.

    The core matchers tests are also using a method to create the pretty print method that is not exposed jasmineUnderTest.makePrettyPrinter().

    Environment

    • Version used: Jasmine v3.99.0 and v4.4.0
    • Environment name and version (e.g. Chrome 39, node.js 5.4): nodejs v16.16.0
    • Operating System and version (desktop or mobile): Windows 10 Enterprise 20H2 19042.1889
    • Link to your project: n/a
    opened by greyepoxy 1
  • v4.2.0 suite-detail CSS class is marked

    v4.2.0 suite-detail CSS class is marked "passed" when test of suite fails

    Expected Behavior

    If a test fails in a suite the suite-detail CSS class should be: jasmine-suite-detail jasmine-failed

    Current Behavior

    If a test fails in a suite the suite-detail CSS class is: jasmine-suite-detail jasmine-passed

    Suite that reproduces the behavior (for bugs)

    See #1976

    Your Environment

    • Chrome 102
    • Operating System: Windows
    help needed 
    opened by rioj7 3
  • Can we have a way to hide excluded tests from test result summary in HTMLReporter?

    Can we have a way to hide excluded tests from test result summary in HTMLReporter?

    Are you creating an issue in the correct repository?

    Yes

    Expected Behavior

    It would be nice to have an option to not print out test results for excluded tests (including non-forced tests).

    Current Behavior

    There appears to be no easy way to do this

    Possible Solution

    In https://github.com/jasmine/jasmine/blob/main/lib/jasmine-core/jasmine-html.js , have another condition in if (filterSpecs && !hasActiveSpec(resultNode)) { which would be a flag we set in the config.

    Suite that reproduces the behavior (for bugs)

    N/A

    Context

    With thousands of tests, when you're running a few tests it seems pointless to list all those other tests that you intentionally didn't fdescribe/fit on.

    Your Environment

    N/A

    feature request help needed 
    opened by Jamie5 3
  • Clock clashes with Zone.js

    Clock clashes with Zone.js

    Expected Behavior

    I would like to have the possibility to run jasmine with Zone.js without any inconveniences. I would have to possibility to load Zone.js after jasmine is bootstrapped.

    Current Behavior

    If Zone.js is loaded before jasmine, it works ok. But if jasmine is loaded before Zone.js, when calling jasmine.clock().install(), I'm getting error Jasmine Clock was unable to install over custom global timer functions. Is the clock already installed?

    Possible Solution

    It occurs because Zone.js overrides global functions like setTimeout, so this is what's happening.

    1. Jasmine is bootstrapped, clock gathers realTimingFunctions (here)
    2. Zone.js is bootstrapped, it overrides global functions (not sure if all, setTimeout for sure).
    3. I call jasmine.clock().install() from the spec code.
    4. Jasmine checks if the clock wasn't installed already by comparison with realTimingFunctions (here. Because those were overridden by Zone.js , it throws an error.

    Possible solution:

    If the only reason for this check is to check if clock was already installed, we can just compare the global functions with our local ones, e.g. !global.setTimeout === self.setTimeout. To make uninstall work properely, we can gather realTimingFunctions directly in the install function. So it would something like:

    
    function originalTimingFunctionsIntact() {
          return (
             !(global.setTimeout === self.setTimeout) &&
              !(global.clearTimeout === self.clearTimeout) &&
              !(global.setInterval === self.setInterval) &&
              !(global.clearInterval === self.clearInterval)
          );
    }
    
    self.install = function() {
          realTimingFunctions = {
              setTimeout: global.setTimeout,
              clearTimeout: global.clearTimeout,
              setInterval: global.setInterval,
              clearInterval: global.clearInterval
          },
    
         if (!originalTimingFunctionsIntact()) {
              throw new Error(
                  'Jasmine Clock was unable to install over custom global timer functions. Is the clock already installed?'
              );
         }
    ...
    }
    

    Suite that reproduces the behavior (for bugs)

    Load jasmine before Zone.js and use clock

    describe("sample", function() {
    jasmine.clock().install();
    });
    

    Context

    I'm using angular setup with nx. With default configuration, it works for apps, but not for libs.

    Your Environment

    • Version used: 3.5.0
    • Environment name and version Chrome 95
    • Operating System and version (desktop or mobile): desktop
    • Link to your project:
    feature request help needed 
    opened by krzysztof-grzybek 2
  • Feature suggestion: jasmine.clock().withMockAsync()

    Feature suggestion: jasmine.clock().withMockAsync()

    In some of my tests, I need to use a mocked clock combined with async functions, basically the equivalent of withMock() that accepts a Promise-returning closure and returns a Promise itself. I already have a home-made wrapper that I use:

    export async function withMockedClock(testBlock: () => Promise<void>): Promise<void> {
      jasmine.clock().install();
    
      return testBlock().finally(() => jasmine.clock().uninstall());
    }
    

    Example usage:

    it('runs async tests with mocked clock', async () => {
      await jasmine.clock().withMockAsync(async () => {
          // setup code
          await expectAsync(promiseReturningFunction()).toBeResolvedTo(...);
      });
    });
    

    Would there be an issue to include something like this in the core library?

    feature request help needed 
    opened by coyoteecd 1
  • afterEach happens in the middle of an async test

    afterEach happens in the middle of an async test

    Expected Behavior

    I expect beforeEach and afterEach procedures to execute before or after tests, never in the middle of a test.

    Current Behavior

    afterEach fires in the middle of an async test.

    Example

    Possible Solution

    Suite that reproduces the behavior (for bugs)

    For example, suppose I have a test like this:

    describe('foo', () => {
      beforeEach(() => console.log('before'))
      afterEach(() => console.log('after'))
    
      it('a', async () => {
        console.log('a1')
        await new Promise(r => setTimeout(r, 10))
        console.log('a2')
      })
    
      it('b', async () => {
        console.log('b1')
        await new Promise(r => setTimeout(r, 10))
        console.log('b2')
      })
    })
    

    The output will contain this:

    b1
    after
    b2
    

    This does not make sense, this does not match with expectations people have when they write synchronous tests: beforeEach and afterEach will never run in the middle of a synchronous test.

    Context

    I was spending hours thinking something is wrong with my code, then I realized that the cleanup code in my afterEach is the culprit because it is destroying things that should be in place for the expectations that remain for the last half of a test.

    Your Environment

    • Version used: 3.9.0
    • Environment name and version: Electron 12 via Karma 6
    • Operating System and version: Manjaro Linux
    • Link to your project: ...
    opened by trusktr 8
Releases(v4.4.0)
🔮 An easy-to-use JavaScript unit testing framework.

QUnit - A JavaScript Unit Testing Framework. QUnit is a powerful, easy-to-use, JavaScript unit testing framework. It's used by the jQuery project to t

QUnit 4k Sep 24, 2022
tap-producing test harness for node and browsers

tape tap-producing test harness for node and browsers example var test = require('tape'); test('timing test', function (t) { t.plan(2); t.eq

James Halliday 5.7k Sep 17, 2022
A Node.js tool to automate end-to-end web testing.

A Node.js tool to automate end-to-end web testing. Write tests in JS or TypeScript, run them and view results. Homepage • Documentation • FAQ • Suppor

Developer Express Inc. 9.4k Sep 20, 2022
☕️ simple, flexible, fun javascript test framework for node.js & the browser

☕️ Simple, flexible, fun JavaScript test framework for Node.js & The Browser ☕️ Links Documentation Release Notes / History / Changes Code of Conduct

Mocha 21.6k Sep 20, 2022
Simple interactive HTTP response mocker, useful for testing API callouts.

Simple interactive HTTP response mocker, useful for testing API callouts.

null 1 Jul 1, 2022
Delightful JavaScript Testing.

?? Delightful JavaScript Testing ????‍?? Developer Ready: A comprehensive JavaScript testing solution. Works out of the box for most JavaScript projec

Facebook 40.2k Sep 16, 2022
The goal of this app is to make user life easier while testing their own apps

Manual testing app The goal of this app is to make user life easier while testing their own apps. It is used to create the testing workflow, record te

null 2 May 1, 2022
blanket.js is a simple code coverage library for javascript. Designed to be easy to install and use, for both browser and nodejs.

Blanket.js A seamless JavaScript code coverage library. FYI: Please note that this repo is not actively maintained If you're looking for a more active

Alex Seville 1.4k Sep 24, 2022
[unmaintained] DalekJS Base framework

DalekJS is not maintained any longer ?? We recommend TestCafé for your automated browser testing needs. dalekjs DalekJS base framework Resources API D

DalekJS 704 Jun 24, 2022
E2E test framework for Angular apps

Protractor Protractor is an end-to-end test framework for Angular and AngularJS applications. Protractor is a Node.js program built on top of WebDrive

Angular 8.8k Sep 18, 2022
Node.js test runner that lets you develop with confidence 🚀

AVA is a test runner for Node.js with a concise API, detailed error output, embrace of new language features and process isolation that lets you devel

AVA 20k Sep 21, 2022
JSCover is a JavaScript Code Coverage Tool that measures line, branch and function coverage

JSCover - A JavaScript code coverage measurement tool. JSCover is an easy-to-use JavaScript code coverage measuring tool. It is an enhanced version of

null 390 Aug 21, 2022
Demo Selenium JavaScript E2E tests (end-to-end web browser automation tests)

Demo Selenium JavaScript E2E tests (end-to-end web browser automation tests)

Joel Parker Henderson 1 Oct 9, 2021
Test runner based on Tape and Browserify

prova Node & Browser Test runner based on Tape and Browserify. Screencasts: node.gif, browser.gif, both.gif, headless browser Slides: slides.com/azer/

Azer Koçulu 334 Jul 19, 2022
Cypress Playback is a plugin and a set of commands that allows Cypress to automatically record responses to network requests made during a test run.

Cypress Playback ?? Automatically record and playback HTTP requests made in Cypress tests. Cypress Playback is a plugin and a set of commands that all

O’Reilly Media, Inc. 4 May 3, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 13 Jul 1, 2022
Javascript client for Sanity. Works in node.js and modern browsers (older browsers needs a Promise polyfill).

@sanity/client Javascript client for Sanity. Works in node.js and modern browsers (older browsers needs a Promise polyfill). Requirements Sanity Clien

Sanity 22 Sep 15, 2022