Skip to content

Commit

Permalink
Merge branch 'features/2559-typescript-support' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
beatfactor committed Mar 22, 2021
2 parents eafeabf + e279ce0 commit 963a6f7
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 3 deletions.
68 changes: 68 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
"nock": "^10.0.6",
"nyc": "^14.1.1",
"selenium-webdriver": "^4.0.0-beta.2",
"ts-node": "^9.1.1",
"typescript": "^4.2.3",
"webdriverio": "^6.6.6"
},
"peerDependencies": {
Expand Down
10 changes: 10 additions & 0 deletions test/sampletests/typescript/sample.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
demoTest: function(client: any) {
client.url('http://localhost')
.assert.elementPresent('#weblogin');
},

after: function(client: any) {
client.end();
}
};
6 changes: 3 additions & 3 deletions test/src/runner/cli/testParallelExecution.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('test Parallel Execution', function() {
assert.ok(runner.test_settings.test_workers);

return runner.runTests().then(_ => {
assert.strictEqual(allArgs.length, 48);
assert.strictEqual(allArgs.length, 49);
assert.strictEqual(runner.concurrency.globalExitCode, 0);
});
});
Expand Down Expand Up @@ -136,7 +136,7 @@ describe('test Parallel Execution', function() {
});

return runner.runTests().then(_ => {
assert.strictEqual(allArgs.length, 48);
assert.strictEqual(allArgs.length, 49);
});
});

Expand Down Expand Up @@ -165,7 +165,7 @@ describe('test Parallel Execution', function() {
});

return runner.runTests().then(_ => {
assert.strictEqual(allArgs.length, 48);
assert.strictEqual(allArgs.length, 49);
});
});

Expand Down
60 changes: 60 additions & 0 deletions test/src/runner/testRunnerTypeScript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
const path = require('path');
const assert = require('assert');
const common = require('../../common.js');
const MockServer = require('../../lib/mockserver.js');
const NightwatchClient = common.require('index.js');

describe('testRunnerTypeScript', function() {
/** @type {import("ts-node").Service} */
let tsNode;

before(function(done) {
tsNode = require('ts-node').register();

this.server = MockServer.init();
this.server.on('listening', () => {
done();
});
});

after(function(done) {
tsNode.enabled(false);

this.server.close(function() {
done();
});
});

beforeEach(function() {
process.removeAllListeners('exit');
process.removeAllListeners('uncaughtException');
process.removeAllListeners('unhandledRejection');
});

it('testRunSimple', function() {
let testsPath = path.join(__dirname, '../../sampletests/typescript');
let globals = {
reporter(results) {
assert.ok('sample' in results.modules);
assert.ok('demoTest' in results.modules['sample'].completed);
assert.strictEqual(results.modules['sample'].modulePath, path.join(__dirname, '../../sampletests/typescript/sample.ts'));

if (results.lastError) {
throw results.lastError;
}
}
};

return NightwatchClient.runTests(testsPath, {
selenium: {
port: 10195,
version2: true,
start_process: true
},
output: false,
persist_globals: true,
globals: globals,
output_folder: false
});
});
});

0 comments on commit 963a6f7

Please sign in to comment.