Skip to content

Commit

Permalink
Merge pull request #583 from ioBroker/mocha-typescript-fix
Browse files Browse the repository at this point in the history
Fix how mocha interacts with TypeScript
  • Loading branch information
AlCalzone authored Sep 11, 2020
2 parents 8877e81 + 09da085 commit 03e6f9e
Show file tree
Hide file tree
Showing 20 changed files with 32 additions and 31 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* (AlCalzone) Make ESLint work in the admin directory, fix most resulting errors (fixes #576)
* (AlCalzone) The year and name placeholders in the Apache License are now correctly replaced (fixes #578)
* (AlCalzone) Added dependabot config for automated dependency updates with auto-merging (#582) · [Migration guide](docs/updates/20200910_dependabot.md)
* (AlCalzone) Fixed how mocha interacts with TypeScript (#583)

## 1.27.0 (2020-09-06)
* (AlCalzone) Add support for TypeScript+React in the Admin UI · [Migration guide](docs/updates/20200902_typescript_react_admin.md)
Expand Down
2 changes: 1 addition & 1 deletion templates/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const templates: { name: string, templateFunction: TemplateFunction }[] = [
{ name: "src/main.ts.ts", templateFunction: require("./src/main.ts") },
{ name: "test/integration.js.ts", templateFunction: require("./test/integration.js") },
{ name: "test/mocha.setup.js.ts", templateFunction: require("./test/mocha.setup.js") },
{ name: "test/mocharc.custom.ts", templateFunction: require("./test/mocharc.custom") },
{ name: "test/package.js.ts", templateFunction: require("./test/package.js") },
{ name: "test/tsconfig.json.ts", templateFunction: require("./test/tsconfig.json") },
{ name: "test/unit.js.ts", templateFunction: require("./test/unit.js") },
Expand Down Expand Up @@ -59,7 +60,6 @@ const templates: { name: string, templateFunction: TemplateFunction }[] = [
{ name: "_github/workflows/dependabot-auto-merge.yml.ts", templateFunction: require("./_github/workflows/dependabot-auto-merge.yml") },
{ name: "_github/workflows/test-and-release.yml.ts", templateFunction: require("./_github/workflows/test-and-release.yml") },
{ name: "_gitignore.ts", templateFunction: require("./_gitignore") },
{ name: "_mocharc.json.ts", templateFunction: require("./_mocharc.json") },
{ name: "_npmignore.ts", templateFunction: require("./_npmignore") },
{ name: "_prettierignore.ts", templateFunction: require("./_prettierignore") },
{ name: "_prettierrc.js.ts", templateFunction: require("./_prettierrc.js") },
Expand Down
4 changes: 2 additions & 2 deletions templates/package.json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ const templateFunction: TemplateFunction = async answers => {
${useReact ? `"watch:parcel": "parcel admin/src/index.tsx -d admin/build${useDevcontainer ? ` --hmr-port 1235` : ""}",` : ""}
"watch:ts": "tsc -p tsconfig.build.json --watch",
"watch": "npm run watch:ts",
"test:ts": "mocha src/**/*.test.ts",
"test:ts": "mocha --config test/mocharc.custom.json src/**/*.test.ts",
`) : (`
"test:js": "mocha \\"{!(node_modules|test)/**/*.test.js,*.test.js,test/**/test!(PackageFiles|Startup).js}\\"",
"test:js": "mocha --config test/mocharc.custom.json \\"{!(node_modules|test)/**/*.test.js,*.test.js,test/**/test!(PackageFiles|Startup).js}\\"",
`)}
"test:package": "mocha test/package --exit",
"test:unit": "mocha test/unit --exit",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as JSON5 from "json5";
import { TemplateFunction } from "../src/lib/createAdapter";
import { TemplateFunction } from "../../src/lib/createAdapter";

const templateFunction: TemplateFunction = answers => {

Expand All @@ -8,7 +8,7 @@ const templateFunction: TemplateFunction = answers => {
const template = `
{
"require": [
"./test/mocha.setup.js",
"test/mocha.setup.js",
${useTypeScript ? (`
"ts-node/register",
"source-map-support/register",
Expand All @@ -27,5 +27,5 @@ ${useTypeScript ? (`
return JSON.stringify(JSON5.parse(template), null, 4);
};

templateFunction.customPath = ".mocharc.json";
templateFunction.customPath = "test/mocharc.custom.json";
export = templateFunction;
4 changes: 2 additions & 2 deletions test/baselines/TS_Prettier/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@types/chai-as-promised": "^7.1.3",
"@types/gulp": "^4.0.6",
"@types/mocha": "^8.0.3",
"@types/node": "^14.10.0",
"@types/node": "^14.10.1",
"@types/proxyquire": "^1.3.28",
"@types/sinon": "^9.0.5",
"@types/sinon-chai": "^3.2.4",
Expand Down Expand Up @@ -57,7 +57,7 @@
"build": "npm run build:ts",
"watch:ts": "tsc -p tsconfig.build.json --watch",
"watch": "npm run watch:ts",
"test:ts": "mocha src/**/*.test.ts",
"test:ts": "mocha --config test/mocharc.custom.json src/**/*.test.ts",
"test:package": "mocha test/package --exit",
"test:unit": "mocha test/unit --exit",
"test:integration": "mocha test/integration --exit",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@types/chai-as-promised": "^7.1.3",
"@types/gulp": "^4.0.6",
"@types/mocha": "^8.0.3",
"@types/node": "^14.10.0",
"@types/node": "^14.10.1",
"@types/proxyquire": "^1.3.28",
"@types/sinon": "^9.0.5",
"@types/sinon-chai": "^3.2.4",
Expand All @@ -43,7 +43,7 @@
},
"main": "main.js",
"scripts": {
"test:js": "mocha \"{!(node_modules|test)/**/*.test.js,*.test.js,test/**/test!(PackageFiles|Startup).js}\"",
"test:js": "mocha --config test/mocharc.custom.json \"{!(node_modules|test)/**/*.test.js,*.test.js,test/**/test!(PackageFiles|Startup).js}\"",
"test:package": "mocha test/package --exit",
"test:unit": "mocha test/unit --exit",
"test:integration": "mocha test/integration --exit",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": [
"./test/mocha.setup.js"
"test/mocha.setup.js"
],
"watch-files": [
"!(node_modules|test)/**/*.test.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@types/chai-as-promised": "^7.1.3",
"@types/gulp": "^4.0.6",
"@types/mocha": "^8.0.3",
"@types/node": "^14.10.0",
"@types/node": "^14.10.1",
"@types/proxyquire": "^1.3.28",
"@types/sinon": "^9.0.5",
"@types/sinon-chai": "^3.2.4",
Expand All @@ -43,7 +43,7 @@
},
"main": "main.js",
"scripts": {
"test:js": "mocha \"{!(node_modules|test)/**/*.test.js,*.test.js,test/**/test!(PackageFiles|Startup).js}\"",
"test:js": "mocha --config test/mocharc.custom.json \"{!(node_modules|test)/**/*.test.js,*.test.js,test/**/test!(PackageFiles|Startup).js}\"",
"test:package": "mocha test/package --exit",
"test:unit": "mocha test/unit --exit",
"test:integration": "mocha test/integration --exit",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": [
"./test/mocha.setup.js"
"test/mocha.setup.js"
],
"watch-files": [
"!(node_modules|test)/**/*.test.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@types/chai-as-promised": "^7.1.3",
"@types/gulp": "^4.0.6",
"@types/mocha": "^8.0.3",
"@types/node": "^14.10.0",
"@types/node": "^14.10.1",
"@types/proxyquire": "^1.3.28",
"@types/sinon": "^9.0.5",
"@types/sinon-chai": "^3.2.4",
Expand All @@ -54,7 +54,7 @@
"build": "npm run build:ts",
"watch:ts": "tsc -p tsconfig.build.json --watch",
"watch": "npm run watch:ts",
"test:ts": "mocha src/**/*.test.ts",
"test:ts": "mocha --config test/mocharc.custom.json src/**/*.test.ts",
"test:package": "mocha test/package --exit",
"test:unit": "mocha test/unit --exit",
"test:integration": "mocha test/integration --exit",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": [
"./test/mocha.setup.js",
"test/mocha.setup.js",
"ts-node/register",
"source-map-support/register"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@types/chai-as-promised": "^7.1.3",
"@types/gulp": "^4.0.6",
"@types/mocha": "^8.0.3",
"@types/node": "^14.10.0",
"@types/node": "^14.10.1",
"@types/proxyquire": "^1.3.28",
"@types/sinon": "^9.0.5",
"@types/sinon-chai": "^3.2.4",
Expand All @@ -54,7 +54,7 @@
"build": "npm run build:ts",
"watch:ts": "tsc -p tsconfig.build.json --watch",
"watch": "npm run watch:ts",
"test:ts": "mocha src/**/*.test.ts",
"test:ts": "mocha --config test/mocharc.custom.json src/**/*.test.ts",
"test:package": "mocha test/package --exit",
"test:unit": "mocha test/unit --exit",
"test:integration": "mocha test/integration --exit",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": [
"./test/mocha.setup.js",
"test/mocha.setup.js",
"ts-node/register",
"source-map-support/register"
],
Expand Down
4 changes: 2 additions & 2 deletions test/baselines/adapter_TS_React/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@types/jquery": "^3.5.1",
"@types/materialize-css": "^1.0.8",
"@types/mocha": "^8.0.3",
"@types/node": "^14.10.0",
"@types/node": "^14.10.1",
"@types/proxyquire": "^1.3.28",
"@types/react": "^16.9.49",
"@types/react-dom": "^16.9.8",
Expand Down Expand Up @@ -72,7 +72,7 @@
"watch:parcel": "parcel admin/src/index.tsx -d admin/build",
"watch:ts": "tsc -p tsconfig.build.json --watch",
"watch": "npm run watch:ts",
"test:ts": "mocha src/**/*.test.ts",
"test:ts": "mocha --config test/mocharc.custom.json src/**/*.test.ts",
"test:package": "mocha test/package --exit",
"test:unit": "mocha test/unit --exit",
"test:integration": "mocha test/integration --exit",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": [
"./test/mocha.setup.js",
"test/mocha.setup.js",
"ts-node/register",
"source-map-support/register"
],
Expand Down
4 changes: 2 additions & 2 deletions test/baselines/contributors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@types/chai-as-promised": "^7.1.3",
"@types/gulp": "^4.0.6",
"@types/mocha": "^8.0.3",
"@types/node": "^14.10.0",
"@types/node": "^14.10.1",
"@types/proxyquire": "^1.3.28",
"@types/sinon": "^9.0.5",
"@types/sinon-chai": "^3.2.4",
Expand All @@ -62,7 +62,7 @@
"build": "npm run build:ts",
"watch:ts": "tsc -p tsconfig.build.json --watch",
"watch": "npm run watch:ts",
"test:ts": "mocha src/**/*.test.ts",
"test:ts": "mocha --config test/mocharc.custom.json src/**/*.test.ts",
"test:package": "mocha test/package --exit",
"test:unit": "mocha test/unit --exit",
"test:integration": "mocha test/integration --exit",
Expand Down
4 changes: 2 additions & 2 deletions test/baselines/git_SSH/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@types/chai-as-promised": "^7.1.3",
"@types/gulp": "^4.0.6",
"@types/mocha": "^8.0.3",
"@types/node": "^14.10.0",
"@types/node": "^14.10.1",
"@types/proxyquire": "^1.3.28",
"@types/sinon": "^9.0.5",
"@types/sinon-chai": "^3.2.4",
Expand All @@ -54,7 +54,7 @@
"build": "npm run build:ts",
"watch:ts": "tsc -p tsconfig.build.json --watch",
"watch": "npm run watch:ts",
"test:ts": "mocha src/**/*.test.ts",
"test:ts": "mocha --config test/mocharc.custom.json src/**/*.test.ts",
"test:package": "mocha test/package --exit",
"test:unit": "mocha test/unit --exit",
"test:integration": "mocha test/integration --exit",
Expand Down
4 changes: 2 additions & 2 deletions test/baselines/keywords/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@types/chai-as-promised": "^7.1.3",
"@types/gulp": "^4.0.6",
"@types/mocha": "^8.0.3",
"@types/node": "^14.10.0",
"@types/node": "^14.10.1",
"@types/proxyquire": "^1.3.28",
"@types/sinon": "^9.0.5",
"@types/sinon-chai": "^3.2.4",
Expand All @@ -55,7 +55,7 @@
"build": "npm run build:ts",
"watch:ts": "tsc -p tsconfig.build.json --watch",
"watch": "npm run watch:ts",
"test:ts": "mocha src/**/*.test.ts",
"test:ts": "mocha --config test/mocharc.custom.json src/**/*.test.ts",
"test:package": "mocha test/package --exit",
"test:unit": "mocha test/unit --exit",
"test:integration": "mocha test/integration --exit",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": [
"./test/mocha.setup.js"
"test/mocha.setup.js"
],
"watch-files": [
"!(node_modules|test)/**/*.test.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": [
"./test/mocha.setup.js"
"test/mocha.setup.js"
],
"watch-files": [
"!(node_modules|test)/**/*.test.js",
Expand Down

0 comments on commit 03e6f9e

Please sign in to comment.