Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do you have any tutorial about exposing the object to be tested and referring a dependency #90

Open
php-max opened this issue Mar 3, 2014 · 5 comments

Comments

@php-max
Copy link

php-max commented Mar 3, 2014

I just guess you made a great lib of qunit. But cannot find any information about how to referring/requiring/my code to be tested and I also need to use sinon to mock something how can I include sinonjs in my testing?

I mean I know the testrunner has some thing like:

{
    code: "path/to/mycode",
}

but how can I get access to my vars, objects and dear sinon.

@kof
Copy link
Contributor

kof commented Mar 3, 2014

There is a deps option for this. See api documentation or shell script help.

@kof kof closed this as completed Mar 3, 2014
@nikolas
Copy link
Contributor

nikolas commented Nov 8, 2014

I'm also having trouble figuring out how to use my objects and vars in my tests.

If I have a runner set up like this:

{
  code: 'lib/cli.js',
  tests: 'tests/unit/test-cli.js'
}

In cli.js I have: module.exports = CLI;. If I try running ok(CLI) in a test in test-cli.js, I get the error: CLI is undefined.

What is the solution? I added my code to deps as well, but that didn't solve the problem.

@kof
Copy link
Contributor

kof commented Nov 9, 2014

exports are merged with global when namespace is not defined. So by default you can access CLI.bla from global.bla or just bla. If you add namespace (see documentation) you will get CLI attached to global using this namespace, f.e. namespace: 'CLI' .... global.CLI === CLI

Its designed to work similar to the browser.

Please submit a pull request for the documentation if I could help you.

@kof kof reopened this Nov 9, 2014
@nikolas
Copy link
Contributor

nikolas commented Nov 9, 2014

I was able to fix this by adding a namespace parameter to my testrunner. Thanks.

@kof
Copy link
Contributor

kof commented Nov 9, 2014

Can you please change the readme file so that you would not stumble over this issue a second time?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants