Skip to content

Commit 9aeec1f

Browse files
committed
Improved Testing
Direct Typescript files will be used in mocha tests instead of transpiled js Moved mocha configuration to .mochrc.json
1 parent 6e9c50a commit 9aeec1f

File tree

8 files changed

+86
-12
lines changed

8 files changed

+86
-12
lines changed

.babelrc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
{
22
"presets": [
3-
"@babel/typescript",
3+
"@babel/preset-typescript",
44
[
55
"@babel/env",
66
{
7-
"targets": "> 0.25%, not dead",
8-
"modules": false
7+
"targets": "> 0.25%, not dead"
98
}
109
]
1110
]

.mocharc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"coverage": true,
3+
"require": ["esm", "./babel-register.js"],
4+
"exit": true,
5+
"timeout": "40000"
6+
}

babel-register.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require("@babel/register")({ extensions: ['.js', '.jsx', '.ts', '.tsx'] });

package-lock.json

Lines changed: 72 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@babel/core": "^7.10.5",
1616
"@babel/preset-env": "^7.10.4",
1717
"@babel/preset-typescript": "^7.13.0",
18+
"@babel/register": "^7.14.5",
1819
"@rollup/plugin-babel": "^5.2.0",
1920
"@rollup/plugin-json": "^4.1.0",
2021
"@rollup/plugin-node-resolve": "^8.4.0",
@@ -37,7 +38,7 @@
3738
"scripts": {
3839
"dev": "rollup -c -w",
3940
"build": "rm -rf dist*;rollup -c",
40-
"test": "export NODE_ENV=test && tsc && nyc ./node_modules/mocha/bin/mocha --coverage -r esm --exit -t 40000 test/*.js;ex=$? ; unset NODE_ENV ; exit $ex;",
41+
"test": "NODE_ENV=test nyc ./node_modules/mocha/bin/mocha test/*.js",
4142
"startSampleApp": "yarn build && cd samples/sample-app/ && yarn install && node index.js",
4243
"report-coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov"
4344
},

test/initialization.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const chai = require("chai");
22
const expect = chai.expect;
33
const initializationParams = require("./data").initializationParams
4-
import ImageKit from "../out-tsc/src/index";
4+
import ImageKit from "../src/index";
55

66

77
describe("Initialization checks", function () {

test/upload.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const sinon = require("sinon");
33
global.FormData = require('formdata-node');
44
const expect = chai.expect;
55
const initializationParams = require("./data").initializationParams
6-
import ImageKit from "../out-tsc/src/index";
6+
import ImageKit from "../src/index";
77
var requests, server;
88

99
const uploadSuccessResponseObj = {

test/url-generation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const pkg = require("../package.json");
33
global.FormData = require('formdata-node');
44
const expect = chai.expect;
55
const initializationParams = require("./data").initializationParams
6-
import ImageKit from "../out-tsc/src/index";
6+
import ImageKit from "../src/index";
77

88
describe("URL generation", function () {
99

0 commit comments

Comments
 (0)