Skip to content

add support for QUnit-based tests #1114

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

Merged
merged 1 commit into from
Oct 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/commands/test-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class TestInitCommand implements ICommand {
}

private frameworkDependencies:IDictionary<string[]> = {
jasmine: [],
mocha: ['chai'],
};

Expand All @@ -33,8 +32,9 @@ class TestInitCommand implements ICommand {
this.$errors.fail(`Unknown or unsupported unit testing framework: ${frameworkToInstall}`);
}

let dependencies = this.frameworkDependencies[frameworkToInstall] || [];
['karma', 'karma-' + frameworkToInstall, 'karma-nativescript-launcher']
.concat(this.frameworkDependencies[frameworkToInstall].map(f => 'karma-' + f))
.concat(dependencies.map(f => 'karma-' + f))
.forEach(mod => {
this.$npm.install(mod, projectDir, {
'save-dev': true,
Expand All @@ -55,7 +55,7 @@ class TestInitCommand implements ICommand {

let karmaConfTemplate = this.$resources.readText('test/karma.conf.js').wait();
let karmaConf = _.template(karmaConfTemplate)({
frameworks: [frameworkToInstall].concat(this.frameworkDependencies[frameworkToInstall])
frameworks: [frameworkToInstall].concat(dependencies)
.map(fw => `'${fw}'`)
.join(', ')
});
Expand Down
2 changes: 1 addition & 1 deletion lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export let PACKAGE_JSON_FILE_NAME = "package.json";
export let NODE_MODULE_CACHE_PATH_KEY_NAME = "node-modules-cache-path";
export let DEFAULT_APP_IDENTIFIER_PREFIX = "org.nativescript";
export var LIVESYNC_EXCLUDED_DIRECTORIES = ["app_resources"];
export var TESTING_FRAMEWORKS = ['jasmine', 'mocha'];
export var TESTING_FRAMEWORKS = ['jasmine', 'mocha', 'qunit'];
export let TEST_RUNNER_NAME = "nativescript-unit-test-runner";

export class ReleaseType {
Expand Down
7 changes: 7 additions & 0 deletions resources/test/example.qunit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// A sample QUnit test
QUnit.test("equal test", function (assert) {
assert.equal( 0, 0, "Zero, Zero; equal succeeds" );
assert.equal( "", 0, "Empty, Zero; equal succeeds" );
assert.equal( "", "", "Empty, Empty; equal succeeds" );
assert.equal( 0, false, "Zero, false; equal succeeds" );
});