Skip to content

Commit

Permalink
Add a failing test for #1696
Browse files Browse the repository at this point in the history
  • Loading branch information
chancancode committed Dec 6, 2023
1 parent 9ea9e87 commit b0abd15
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/scenarios/v2-addon-dev-watch-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { baseV2Addon } from './scenarios';
import type { PreparedApp } from 'scenario-tester';
import { Scenarios } from 'scenario-tester';
import fs from 'fs/promises';
import { pathExists } from 'fs-extra';
import QUnit from 'qunit';
import merge from 'lodash/merge';
import { DevWatcher, becomesModified, isNotModified } from './helpers';
Expand Down Expand Up @@ -185,6 +186,35 @@ Scenarios.fromProject(() => baseV2Addon())
},
});
});

test('adding a new file triggers a re-build', async function (assert) {
watcher = new DevWatcher(addon);

await watcher.start();

const src = path.join(addon.dir, 'src/components/foo.js');
const dist = path.join(addon.dir, 'dist/components/foo.js');

assert.false(await pathExists(src), 'src/components/foo.js does not exist');
assert.false(await pathExists(dist), 'dist/components/foo.js does not exist');

await fs.writeFile(
src,
`
import Component from '@glimmer/component';
export default class FooComponent extends Component {}
`
);

assert.true(await pathExists(src), 'src/components/foo.js exists');

await watcher.nextBuild();

assert.true(
(await fs.readFile(dist)).includes('FooComponent'),
'dist/components/foo.js exists and has the right content'
);
});
});

test('the package.json *is* updated on a rebuild, since public assets changed', async function (assert) {
Expand Down

0 comments on commit b0abd15

Please sign in to comment.