wallabyjs / public

Repository for Wallaby.js questions and issues
http://wallabyjs.com
759 stars 45 forks source link

Chutzpah tests fail with wallabyjs in Visual Studio #174

Open saifmd4u opened 9 years ago

saifmd4u commented 9 years ago

We have got our unit tests that are run as part of the build which uses Chutzpah. Now those tests fail in wallabyjs because it does not consider following references

/// reference path="../../../../../Scripts/underscore.js" />

Basically I would like to isolate the dependencies for each "xxxxx.test.js" and would not want a seperate json for each file.

Is there a way to fix this in wallaby-qunit.json or Is it something wallaby supports in future.

ArtemGovorov commented 9 years ago

You may just specify a list of all dependencies in one wallaby json file. So if you have a.test.js that depends on x.js and y.js, and b.test.js that depends on y.js and z.js, then your wallaby.json file may look like:

{
  "files": [
    "src/x.js",
    "src/y.js"
    "src/z.js"
  ],
  "tests": ["test/*.test.js"]
}

Does this solution work for you?

saifmd4u commented 9 years ago

My use case is different. I want dependency of x.js in test1.js. But I want to mock x.js in test2.js which means x.js should be hidden for test2.js.

Also can I have wallaby-qunit-1.16.0.json in a folder rather than at the root.

Will there a future enhancement to use the dependencies based on 'reference' mentioned in the file.

Thanks

ArtemGovorov commented 9 years ago

Thanks for the explanation.

At the moment, wallaby.js doesn't run each test file in isolation from others, it may not be very performant to load all dependencies again and again for each test file, for example libraries that most of tests/source files depend on.

Having said that, in future I may implement parsing reference comments (was planning it for TypeScript as well) and the opt-in option to run each test file in an isolated harness. One thing to keep in mind is that using the option will always be slower than allowing to use non-isolated sandboxes (and perhaps some different mocking mechanism, such as sinon). So marking the issue as an enhancement to be implemented in future.