Skip to content

Commit 14a995a

Browse files
committed
Merge pull request #1114 from NativeScript/sd/qunit
add support for QUnit-based tests
2 parents 2d1f224 + 60b6335 commit 14a995a

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

lib/commands/test-init.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class TestInitCommand implements ICommand {
1919
}
2020

2121
private frameworkDependencies:IDictionary<string[]> = {
22-
jasmine: [],
2322
mocha: ['chai'],
2423
};
2524

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

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

5656
let karmaConfTemplate = this.$resources.readText('test/karma.conf.js').wait();
5757
let karmaConf = _.template(karmaConfTemplate)({
58-
frameworks: [frameworkToInstall].concat(this.frameworkDependencies[frameworkToInstall])
58+
frameworks: [frameworkToInstall].concat(dependencies)
5959
.map(fw => `'${fw}'`)
6060
.join(', ')
6161
});

lib/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export let PACKAGE_JSON_FILE_NAME = "package.json";
1212
export let NODE_MODULE_CACHE_PATH_KEY_NAME = "node-modules-cache-path";
1313
export let DEFAULT_APP_IDENTIFIER_PREFIX = "org.nativescript";
1414
export var LIVESYNC_EXCLUDED_DIRECTORIES = ["app_resources"];
15-
export var TESTING_FRAMEWORKS = ['jasmine', 'mocha'];
15+
export var TESTING_FRAMEWORKS = ['jasmine', 'mocha', 'qunit'];
1616
export let TEST_RUNNER_NAME = "nativescript-unit-test-runner";
1717

1818
export class ReleaseType {

resources/test/example.qunit.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// A sample QUnit test
2+
QUnit.test("equal test", function (assert) {
3+
assert.equal( 0, 0, "Zero, Zero; equal succeeds" );
4+
assert.equal( "", 0, "Empty, Zero; equal succeeds" );
5+
assert.equal( "", "", "Empty, Empty; equal succeeds" );
6+
assert.equal( 0, false, "Zero, false; equal succeeds" );
7+
});

0 commit comments

Comments
 (0)