Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

1.4 KB
Raw Blame
"use strict";

var path = require("node:path").posix;
var helpers = require("../helpers.cjs");
var runMochaJSON = helpers.runMochaJSON;

describe("--delay", function () {
  var args = ["--delay", "--no-forbid-only"];

  it("should run the generated test suite", function (done) {
    var fixture = path.join("options", "delay.fixture.cjs");
    runMochaJSON(fixture, args, function (err, res) {
      if (err) {
        return done(err);
      }

      expect(res, "to have passed").and("to have passed test count", 1);
      done();
    });
  });

  it("should execute exclusive tests only", function (done) {
    var fixture = path.join("options", "delay-only.fixture.cjs");
    runMochaJSON(fixture, args, function (err, res) {
      if (err) {
        return done(err);
      }

      expect(res, "to have passed")
        .and("to have passed test count", 2)
        .and(
          "to have passed test order",
          "should run this",
          "should run this, too",
        );
      done();
    });
  });

  it("should throw an error if the test suite failed to run", function (done) {
    var fixture = path.join("options", "delay-fail.fixture.js");
    runMochaJSON(fixture, args, function (err, res) {
      if (err) {
        return done(err);
      }

      expect(res, "to have failed").and(
        "to have failed test",
        "Uncaught error outside test suite",
      );
      done();
    });
  });
});