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
Test helpers for BroccoliPlugins that make testing build and rebuild behavior dead simple and expect diff friendly.
import { expect } from "chai";
import { createBuilder, createTempDir } from "broccoli-test-helper";
import MyBroccoliPlugin from "../index";
describe("MyBroccoliPlugin", () => {
let input;
let output;
let subject;
beforeEach(async () => {
input = await createTempDir();
subject = new MyBroccoliPlugin(input.path());
output = createBuilder(subject);
});
afterEach(async () => {
await input.dispose();
await output.dispose();
});
it("should build", async () => {
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 {};`
}
});
await output.build();
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 {};`
}
});
await output.build();
expect(
output.changes()
).to.deep.equal({
});
input.write({
"index.js": "export class A {};",
"lib": null // delete dir
});
await output.build();
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 {};`
});
});
});