karma-runner / karma-qunit

A Karma plugin. Adapter for QUnit testing framework.
MIT License
51 stars 38 forks source link

running qUnit test: test is not defined #99

Closed SlavikCA closed 6 years ago

SlavikCA commented 6 years ago

I'm trying to use this plugin to run qUnit tests.

Here my build.gradle:

plugins {
    id 'com.craigburke.karma' version '1.4.4'
}

karma {
    browsers = ['Chrome']
    frameworks = ['qunit']
    dependencies (['karma-qunit'])
    files = [
            'src/main/js/*.js'
    ]
 }

And here is the one and only qUnit test case:

test("This is another test", 1, function () { // use the "expected" param to register how many
    // assertions to Expect to be run within this test.
    ok(true, 'Look, a message!');
});

When I run gradle karmaRun, I'm see it opens new browser, and then fails with this error:

sfursov-mac:gradle-qunit sfursov$ gradle karmaRun

> Task :karmaRun
Chrome 63.0.3239 (Mac OS X 10.13.3) ERROR
  {
    "message": "Uncaught ReferenceError: test is not defined\nat src/main/js/test.js:1:1\n\nReferenceError: test is not defined\n    at src/main/js/test.js:1:1",
    "str": "Uncaught ReferenceError: test is not defined\nat src/main/js/test.js:1:1\n\nReferenceError: test is not defined\n    at src/main/js/test.js:1:1"
  }

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':karmaRun'.
> Process 'command '/Users/sfursov/.gradle/nodejs/node-v4.2.3-darwin-x64/bin/node'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 13s
4 actionable tasks: 1 executed, 3 up-to-date

Here is complete project: https://github.com/SlavikCA/gradle-qunit

Environment:

Any idea, what I'm not doing right? Do I need to add qUnit dependency some other way?

SlavikCA commented 6 years ago

ok, I figured. I had to change path of files to include all dependencies: https://github.com/SlavikCA/gradle-qunit/commit/8f66a7c35462f29534f8971f6623f95d42bb6b11

Now, I'm getting other issues... But this one is done.