Skip to content

Commit

Permalink
Basic support for unit testing added yeoman#759
Browse files Browse the repository at this point in the history
- Babel config now supports modules (imp/exp)
-  Added module support in the index.html
-  Added sample function in main.js for future unit testing
- Tests updated
  • Loading branch information
UlisesGascon committed Jun 5, 2019
1 parent f541cd6 commit 0b05190
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
9 changes: 7 additions & 2 deletions app/templates/babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"presets": [
"@babel/preset-env"
["@babel/preset-env", {
"sourceType": "unambiguous",
"targets": {
"esmodules": true
}
}]
]
}
}
4 changes: 4 additions & 0 deletions app/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ <h1>'Allo, 'Allo!</h1>
<%_ } -%>
<!-- endbuild -->
<!-- build:js scripts/main.js -->
<%_ if (includeUnit) { -%>
<script type="module" src="scripts/main.js"></script>
<%_ } else { -%>
<script src="scripts/main.js"></script>
<%_ } -%>
<!-- endbuild -->
</body>
</html>
10 changes: 9 additions & 1 deletion app/templates/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
console.log('\'Allo \'Allo!');
<%_ if (includeUnit) { -%>
export function greeting() {
return '\'Allo \'Allo!';
}

console.log(greeting());
<%_ } else { -%>
console.log('\'Allo \'Allo!');
<%_ } -%>

<%_ if (includeBootstrap) { -%>
// Uncomment to enable Bootstrap tooltips
Expand Down

0 comments on commit 0b05190

Please sign in to comment.