Closed hcbh96 closed 5 years ago
For anyone else asking this question I've dug a bit deeper with this ... understanding GULP is really helpful and here is a great video to help you do just that
https://www.youtube.com/watch?v=1rw9MfIleEg
This issue helps to understand what I was doing wrong
https://teamtreehouse.com/community/having-trouble-testing-in-yeoman-gulpwebapp
Basically though the test suit in my case does work!! π€¦ββοΈ
I just needed to change the script tag for ...
<script type="text/javascript" src="../app/scripts/textarea-auto-resize.js"></script>
to
<script type="text/javascript" src="/scripts/textarea-auto-resize.js"></script>
This is because when running
"serve:test": "cross-env NODE_ENV=test gulp serve",
The Gulp file calls this series...
serve = series(clean, scripts, startTestServer);
The final function in this series looks like so...
server.init({
notify: false,
port,
ui: false,
server: {
baseDir: 'test',
routes: {
'/scripts': '.tmp/scripts',
'/node_modules': 'node_modules',
},
},
});
And under routes you can see the '/scripts': '.tmp/scripts',
Therefore my script inclusion tag has to start with /scripts
instead of ../app/scripts
I've learned lots and now get and like gulp π so I am one happy coder π€
There are two similar threads to this at #4 - the answer provided leads to this #101
I havn't found that any of them yet really answer the question of how to inlcude the source files I want to test - I'm gonna go onto read the gulp documentation https://github.com/gulpjs/gulp/tree/master/docs
I am currently trying to unit test the following function I've included my source and spec files like so
The problem is of course that this
../app/scripts/textarea-auto-resize.js
doesn't work as the folder structure is like soI beleive I need to add something more to my gulpfile or my gulpfile is slightly off but not quite sure yet - the scripts function in the gulp file looks like so...