jstransformers / boilerplate

Boilerplate for JSTransformers. See the Wiki for documentation...
https://github.com/jstransformers/boilerplate/wiki
MIT License
5 stars 1 forks source link

Tests #20

Closed ForbesLindesay closed 9 years ago

ForbesLindesay commented 9 years ago

We should do one of two things with the tests:

  1. If we are really going for one set of tests that will be used for all jstransformers, we should make it a CLI that expects a "test" directory containing "expected.txt", "input.txt", "locals.json" & "options.json". This CLI should also have a mode where it uses istanbul to generate code coverage.
  2. If we plan to include the JavaScript for running tests in every repository, we should instead make it "delete as applicable", rather than a series of if statements.

I'm going to work on writing up option 1, since this seems to be the way we are moving with what's currently there and it will make it easier to ensure all jstransformers have the same level of test coverage. I also intend to require the test case to explicitly state which endpoints expose "dependencies", since as jstransformers/jstransformer-jade#1 demonstrates, it's not entirely clear to implementers what is required.

RobLoach commented 9 years ago

Three things:

  1. Was also thinking there might be cases where we have multiple test cases:

    tests/1/expected.txt
    tests/1/input.txt
    tests/1/options.json
    tests/1/locals.json
    tests/2/expected.txt
    tests/2/input.txt
    tests/2/options.json
    tests/2/locals.json
  2. The other transform that doesn't quite meet this testing standard is webpack. https://github.com/jstransformers/jstransformer-webpack/blob/master/test/index.js ... It compiles outside of the returned results, so that might be expected.
  3. jstransformer-tester? Or test-jstransformer, so that it's not mistaken as a transform?
ForbesLindesay commented 9 years ago
  1. Yes, lets support that as an option as well.
  2. It looks like webpack should have a completely custom test suite and not try to adhear to the boilerplate test suite anyway. It's debatable whether it should even be considered a jstransformer at all since it's not really string -> string but rather files -> files. I think it should have a prominent note in the readme that it is un-usual/not a good reference implementation of a jstransformer.
  3. test-jstransformer sounds a little odd, but it makes a lot of sense as a command name and I think it's very important to make sure that our utils don't get confused with our transformers.
RobLoach commented 9 years ago

In Boilerplate......

  1. npm i test-jstransformer --save-dev
  2. "scipts": {"test": "test-jstransformer tests"}, or something, or maybe tests is the default folder it checks

https://github.com/jstransformers/test-jstransformer