Skip to content

Commit

Permalink
Add testing capability in TypeScript (#282)
Browse files Browse the repository at this point in the history
* Move deprecated mocha.opts to .mocharc.js

* Add typescript

* add ts-node

* Add and run dummy test in TypeScript

* Make the first TypeScript test meaningful

* Split the types of tests

* restore ToC
  • Loading branch information
mhaligowski authored Nov 30, 2023
1 parent 08d98f4 commit 79e42b2
Show file tree
Hide file tree
Showing 8 changed files with 494 additions and 21 deletions.
8 changes: 8 additions & 0 deletions .mocharc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"use strict";

module.exports = {
recursive: true,
reporter: "spec",
require: 'ts-node/register',
ui: "bdd",
};
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,15 @@ Or:
Failures in the linting process may fail our continuous integration builds.
### TypeScript tests
It's also possible to implement tests in TypeScript, primarily for the purpose of testing the TypeScript definitions. To run these tests, use:

npm run test:ts

Note: at this point ESLint is not ran against TypeScript tests.


Thanks again for helping out!


Expand Down
13 changes: 12 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ var eslint = require('gulp-eslint');

var files = {
src: ['./lib/**/*.js'],
test: ['./test/**/*.spec.js', './*.js']
test: ['./test/**/*.spec.js', './*.js'],
testTs: ['./test/**/*.spec.ts']
};

gulp.task('lint', function () {
Expand All @@ -27,11 +28,21 @@ gulp.task('dot', function () {

gulp.task('test', gulp.series('dot', 'lint'));

gulp.task('test:ts', function () {
return gulp.src(files.testTs, {read: false})
.pipe(mocha({reporter: 'dot', require: 'ts-node/register'}));
});

gulp.task('spec', function () {
return gulp.src(files.test, {read: false})
.pipe(mocha({reporter: 'spec'}));
});

gulp.task('spec:ts', function () {
return gulp.src(files.testTs, {read: false})
.pipe(mocha({reporter: 'spec'}));
});

gulp.task('coverage', function (done) {
gulp.src(files.src)
.pipe(istanbul())
Expand Down
Loading

0 comments on commit 79e42b2

Please sign in to comment.