Skip to content

Commit

Permalink
fix: register lodash template loader in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandro Mesterheide committed Nov 26, 2024
1 parent a25ba10 commit cdf53f2
Show file tree
Hide file tree
Showing 3 changed files with 267 additions and 20 deletions.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,10 @@
"devDependencies": {
"@formio/js": "5.0.0-rc.76",
"@types/chai": "^4.2.11",
"@types/ejs": "^3.0.2",
"@types/mocha": "^10.0.1",
"@types/node": "^18.15.5",
"@types/sinon": "^10.0.13",
"chai": "^4.2.0",
"ejs": "^3.1.10",
"ejsify": "^1.0.0",
"esm": "^3.2.25",
"eventemitter3": "^5.0.1",
"gulp": "^4.0.2",
Expand All @@ -62,6 +59,7 @@
"mocha": "^10.2.0",
"native-promise-only": "^0.8.1",
"nyc": "^15.0.1",
"pirates": "^4.0.6",
"pre-commit": "^1.2.2",
"sass": "^1.59.3",
"sinon": "^15.0.2",
Expand Down
18 changes: 15 additions & 3 deletions register.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
const _ = require('lodash');
const pirates = require('pirates');

/**
* Overrides the tsconfig used for the app.
* In the test environment we need some tweaks.
*/

const tsNode = require('ts-node');
const tsNode = require('ts-node');

tsNode.register({
tsNode.register({
files: true,
transpileOnly: true,
project: './tsconfig.spec.json'
});
});

pirates.addHook((code) => {
return 'export default ' + _.template(code, {
evaluate: /\{%([\s\S]+?)%\}/g,
interpolate: /\{\{([\s\S]+?)\}\}/g,
escape: /\{\{\{([\s\S]+?)\}\}\}/g,
variable: 'ctx'
});
}, { exts: ['.ejs'] });
Loading

0 comments on commit cdf53f2

Please sign in to comment.