Sorry for the lame question, but I did not manage to understand how the server:test (but alose the test) command works w/r to the app.
Reading the code it seems that server:test do "mount" the test directory and the temp directory.
However the temp directory is not created by default (i.e. you need to build to create it, and still it will create versioned js files).
Actually I do not understand how the server:test can have visibility on my app script.
Shouldn't the app directory be mounted instead of the temp one ?
Hi Frederick ,
You're absolutely true. The server:test profile right now doesn't serve the app/ dir. Actually, it was a bit naive and just change the default app/ root dir to the test/ one. And we'll most likely need to access the files that are within app/ to be able to test them.
I'm starting to think that on server:test profile, we actually need to "mount" everything, app/, temp/ and test/. With test/ configured first, so that we serve test/index.html instead of the app one.
^ I agree.
Yeaahhh ... I wrapped my head this afternoon and was not sure to understand it ;)
Happy to see I got it ;)
I'm going to try to make it work and submit a pull request ;)
Also, what is the rationale behind "mounting" the temp directory ?
If I understand correctly, in the case of server:app we have:
grunt.task.run('clean coffee compass open-browser');
My understanding is that this process should be the same for server:test as we want to be sure coffee / compass are triggered before running our tests.
In the case of server:dist, I guess that we do not want to have temp mounted.
The special server:reload target is said to act as app, so I would tend to say that in this case in this not needed too ...
Am I missing something ?
Attempt to fix Issue #443
As highlighted in Issue #459, I do think there's a flaw in the what we're mounting for a test server:
So, my point of view would be to say that if we do want to be coherent and have html file that can be used both through phantomjs and when displayed by a server:test, we should, for server:test task, mount the whole project directory, and load the test/index.html file in the browser.
So far this is the only way I can see to have a single html file that can serve both purposes.
What do you think of that ?
@sleeper I think it's a definitely valid concern. Actually, this is what we used to have before the changes related to compilation output (in temp/) and the bits of magic added to make server:app serve both directories.
OK, so I would propose the following:
This way, both the test and server:test would have the same "visibility' on the project.
Are you OK with this ? If yes, I'll update my commit to reflect this.
I like it. In the meantime, I'm checking and playing with your fix_server_test branch right now. I'm trying to make the phantomjs environment use our server:test environment.
(just testing with the mocha part, to redo with Jasmine) Files are loaded through the file:// protocol, funny enough you can trick the task by changing the config with:
// tests: ['tests/**/*.html'],
If it works as expected, it should let us use the exact same runner for both environments, while still keeping that behaviour of serving both test/ and app/ as root directories.
I'm just struggling with the server task itself, to find a way to prevent the last task watch to be run. It's then a matter of aliasing test (internally or on purpose in user's gruntfile) to be something like: grunt.registerTask('test', 'server:test mocha');.
grunt.registerTask('test', 'server:test mocha');
Good idea ... I saw that files were loaded though `file://' and didn't go further down the road ... Good to know you can overwrite this !
Regarding the last watch: I made the server:test use the same as the server:app as in dev mode, I'll need to have my modified scripts reloaded...
So I did not try this but if we set back to normal (i.e. only the server:app will run the coffe, compass and watch stuff, and play with aliasing for the server:test by itself ?
Confirmed! It worked.
I simply commented out the watch and open-task for now, and aliased test to run server:test mocha with the config posted above.
Maybe, we can add one more additional target, make the generators alias grunt.registerTask('test', 'server:phantom mocha'); (or do it internally, in one of our task file). And prevent both watch / open-browser task to run in this configuration (when target === 'phantom').
grunt.registerTask('test', 'server:phantom mocha');
target === 'phantom'
I'm going to give it a try tonight, and add the server:phantomjs as you proposed.
Ok. With this commit (rebased and stashed):
I'm going to submit a PR on the generator repo to alias the test target to server:phantom <which ever test framework you're using>.
server:phantom <which ever test framework you're using>
Will also fix #438 (after a change in the Gruntfile)
It ensure that:
- the server:test have visibility on test, temp and app directories
- the test target is first launching a server dedicated to phantom