gulp-community / gulp-wrap-amd

Wrap file with an AMD wrapper
MIT License
21 stars 13 forks source link

Update the testing framework from tab to lab with code assertion library #14

Open mattma opened 9 years ago

mattma commented 9 years ago

A while back, we have discussed on how to use the testing framework - Tab. You are not fully satisfied with it and intend to switch to Lab. I have already seen that you have tried Lab/Code in your latest git repo project.

I started to take a crack at it. Here is what I get so far. It is not in the merging stage with a few issues.

  1. In npm test scripts, use lab with coverage flag, got message in output after running the test. template.js missing coverage on line(s). I think that we are ignoring the template.js in this case. How to setup in lab command?
  2. By including the test stream.js, it has doubled our test cases. I think it is the natural event listeners which is fired when the test.js test executed. But in Tab, it only outputs two tests, which is total of 16 test cases instead of 26.
  3. in test.js, line 33, I did not like the way that it has to call done(), then cb() styles. In through2, it requires to call cb(). In Lab, it requires to pass in an argument of done. How could I make it more elegant?
  4. isolate the contents of the individual files includes two different files for testing. If I remove the skip, it will actually run the test, then output an warning. Multiple callbacks or thrown errors received in test: WrapAmd module should isolate the contents of the individual files (done).
phated commented 9 years ago

I took a look at this. Thinking maybe we should do something differently than expectStream since we have to call done now instead of using t.plan to plan the number of assertions.

mattma commented 9 years ago

Yes. I agree. ExpectStream would have always call cb() to pass the control back to through2. Calling done() before cb() is totally a hack. We are doing two separated logic in one function is not permitted.

Do you think creating a plain Vinyl and paring with a pure stream is the way to go?

phated commented 9 years ago

Yeah, I think that writing a vinyl object to the wrap stream makes more sense than using gulp. Many plugins switched to that pattern.

mattma commented 9 years ago

OK. It is time to write some UNIT tests. Ha Ha Ha...

mattma commented 9 years ago

I have not forgotten about this, just have been busy working on several other things. I will get back with it soon.