Open calebeby opened 8 years ago
@jescalan can you look at this?
Hi @calebeby! Sorry for the delay, I've been tied up with some projects recently. This looks good, could you add a simple test to verify that it's working, potentially?
I haven't written tests before, is it documented how to do this?
In which file are the tests for the server?
@calebeby this is probably the closest match. this is a pretty tough test to start on - let me know if it's too confusing!
https://github.com/jescalan/roots/blob/master/test/watcher.coffee
Here's the plan:
watcher.coffee
add a test that does the following:
roots
from browsersync fixtureWhich feature of Browsersync would be easiest to test? There is a list of them here. I was thinking the UI address, but I don't see a http request tester in mocha. We would have to do something like this.
What do you think?
@calebeby so really the only thing you need to test is that the options are being passed through to browsersync correctly. they have tests for their own features, we just need to be sure the configuration is being passed to it!
In the watcher.coffee
file is it using the compile/basic
fixture? That fixture does not have an app.coffee
. Should I add one, or make a new fixture? If I make a new fixture, how is the fixture started by the test? How do I check variables in local_server.coffee
from within the test?
Wow. I have a lot of questions today :smile:
@calebeby So it will use whatever fixture you pass in when initializing the watcher class seen here, which for the existing test is basic.
If you need a new app.coffee, you're welcome to make a new fixture and pass that in, or you can pass your config options to the roots class when you initialize it, see js api docs
To check the variables passed through the internals, you can use the mockery package, you can see it at work in the CLI tests here. I think the approach here would be to replace browserify with a mock, then check the config coming into it through the mock
Hope this helps, and fire away with any more questions! This is definitely on the more complex end of tests that could be written, so big props for jumping in and going for it 😁
Browsersync is now configurable by: