JSPM

broccoli-test-helper

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7469
  • Score
    100M100P100Q135826F
  • License MIT

Test helpers for BroccoliPlugins that make testing build and rebuild behavior dead simple and expect diff friendly.

Package Exports

  • broccoli-test-helper

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (broccoli-test-helper) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

broccoli-test-helper

Build status Build Status

Test helpers for BroccoliPlugins that make testing build and rebuild behavior dead simple and expect diff friendly.

import { expect } from "chai";
import { buildOutput, createTempDir } from "broccoli-test-helper";
import MyBroccoliPlugin from "../index";

describe("MyBroccoliPlugin", () => {
  let input;

  beforeEach(() => createTempDir().then(tempDir => {
    input = tempDir;
  }));

  afterEach(() => input.dispose());

  it("should build", () => {
    input.write({
      "index.js": `export { A } from "./lib/a";`
      "lib": {
        "a.js": `export class A {};`,
        "b.js": `export class B {};`,
        "c.js": `export class C {};`
      }
    });

    return buildOutput(
      new MyBroccoliPlugin(input.path())
    ).then(output => {
      expect(
        output.read()
      ).to.deep.equal({
        "index.js": `exports.A = require("./lib/a").A;`,
        "lib": {
          "a.js": `exports.A = class A {};`,
          "b.js": `exports.B = class B {};`,
          "c.js": `exports.C = class C {};`
        }
      });

      // rebuild noop
      return output.rebuild();
    }).then(output => {
      expect( output.changes() ).to.deep.equal({ });

      input.write({
        "index.js": "export class A {};",
        "lib": null // delete dir
      });

      // rebuild changes
      return output.rebuild();
    }).then(output => {
      expect( output.changes() ).to.deep.equal({
        "lib/c.js": "unlink",
        "lib/b.js": "unlink",
        "lib/a.js": "unlink",
        "lib/":     "rmdir",
        "index.js": "change"
      });

      expect( output.read() ).to.deep.equal({
        "index.js": `exports.A = class A {};`
      });
    });
  });
});