Skip to content

Commit 5da75de

Browse files
committed
Add CI test verifying Mustache works with CommonJS
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.
1 parent 1053567 commit 5da75de

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

.github/workflows/verify.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,22 @@ jobs:
3838
run: |
3939
npm install mocha@3 chai@3
4040
npm run test-unit
41+
42+
common-js-usage:
43+
runs-on: ubuntu-latest
44+
45+
steps:
46+
- uses: actions/checkout@v1
47+
- name: Setup Node.js
48+
uses: actions/setup-node@v1
49+
with:
50+
node-version: 12.x
51+
- name: Package, install and test
52+
run: |
53+
export ARCHIVE_FILENAME=$(npm pack | tail -n 1)
54+
export UNPACK_DESTINATION=$(mktemp -d)
55+
mv $ARCHIVE_FILENAME $UNPACK_DESTINATION
56+
cp test/module-systems/commonjs-test.js $UNPACK_DESTINATION
57+
cd $UNPACK_DESTINATION
58+
npm install $ARCHIVE_FILENAME
59+
node commonjs-test.js

test/module-systems/.eslintrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "../.eslintrc",
3+
"parserOptions": {
4+
"ecmaVersion": 2017
5+
}
6+
}

test/module-systems/commonjs-test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const assert = require('assert');
2+
const mustache = require('mustache');
3+
4+
const view = {
5+
title: 'Joe',
6+
calc: () => 2 + 4
7+
};
8+
9+
assert.strictEqual(
10+
mustache.render('{{title}} spends {{calc}}', view),
11+
'Joe spends 6'
12+
);

0 commit comments

Comments
 (0)