Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4828

Best way to test what files my addon is providing to host app

$
0
0

@samselikoff wrote:

I’m trying to update an old Mirage test that verifies production builds of Mirage strip out nearly all of its files from the build.

Robert mentioned that the current test is brittle because it’s too implementation specific, so I’m trying to rewrite these tests using broccoli-test-helper.

Here’s what I have so far:

it('includes all mirage modules in development', async() => {
  let addon = new EmberAddon();
  output = createBuilder(addon.toTree());
  await output.build();

  let files = output.read();
  let mirageModulesInBuild = files.assets['vendor.js']
    .split('\n')
    .filter(line => line.match(";define\\('ember-cli-mirage"));

  expect(mirageModulesInBuild.length).to.be.above(1);
});

I hit some roadblocks when I proceeded to write the next test, asserting only 1 file ended up in production builds, because (a) the vendor.js is now fingerprinted and (b) the contents of the file are minified, making it impossible to search for mirage strings.

I’m sure there’s a better way to assert against what files my addon makes available to the host app, but just poking around output I wasn’t able to find anything. Could someone point me in the right direction, or show me some examples from other addons writing these sorts of tests?

Posts: 6

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4828

Trending Articles