From 9452eafd642c7bf827fa0627bd493e1fdf48da94 Mon Sep 17 00:00:00 2001 From: Phillip Johnsen Date: Wed, 30 Oct 2019 10:27:39 +0100 Subject: [PATCH] Add CI test verifying Mustache works in browser as AMD w/RequireJS This is a precursor to introducing a build step that will change what we expose from this package. Better off writing some tests to verify existing projects with different module systems continue to work as expected. --- test/module-systems/_fixtures/amd.html | 26 ++++++++++++++++++++++++++ test/module-systems/browser-test.js | 12 ++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 test/module-systems/_fixtures/amd.html diff --git a/test/module-systems/_fixtures/amd.html b/test/module-systems/_fixtures/amd.html new file mode 100644 index 0000000..5a5b268 --- /dev/null +++ b/test/module-systems/_fixtures/amd.html @@ -0,0 +1,26 @@ + + + + + + +Text content to be overwritten + diff --git a/test/module-systems/browser-test.js b/test/module-systems/browser-test.js index 05d4a71..c58c231 100644 --- a/test/module-systems/browser-test.js +++ b/test/module-systems/browser-test.js @@ -34,4 +34,16 @@ describe('Browser usage', () => { chai.assert.equal(value.trim(), 'Joe spends 6'); }); + + it('is exposed as AMD and consumable via RequireJS', async function () { + this.timeout(10 * 1000); + + await page.goto(`file://${path.join(__dirname, '_fixtures/amd.html')}`, { waitUntil: 'networkidle0' }); + + const bodyElement = await page.$('body'); + const textContentProperty = await bodyElement.getProperty('textContent'); + const value = await textContentProperty.jsonValue(); + + chai.assert.equal(value, 'Joe spends 6'); + }); });