Skip to content

Commit

Permalink
add std test environment
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm1957 committed Feb 20, 2024
1 parent 88a4dd3 commit b8758d8
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 0 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
"main.js"
],
"scripts": {
"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:integration": "mocha test/integration --exit",
"test": "npm run test:js && npm run test:package",
"check": "tsc --noEmit -p tsconfig.check.json",
"lint": "eslint .",
"translate": "translate-adapter",
Expand Down
5 changes: 5 additions & 0 deletions test/integration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const path = require('path');
const { tests } = require('@iobroker/testing');

// Run integration tests - See https://github.com/ioBroker/testing for a detailed explanation and further options
tests.integration(path.join(__dirname, '..'));
14 changes: 14 additions & 0 deletions test/mocha.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Don't silently swallow unhandled rejections
process.on('unhandledRejection', (e) => {
throw e;
});

// enable the should interface with sinon
// and load chai-as-promised and sinon-chai by default
const sinonChai = require('sinon-chai');
const chaiAsPromised = require('chai-as-promised');
const { should, use } = require('chai');

should();
use(sinonChai);
use(chaiAsPromised);
4 changes: 4 additions & 0 deletions test/mocharc.custom.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"require": ["test/mocha.setup.js"],
"watch-files": ["!(node_modules|test)/**/*.test.js", "*.test.js", "test/**/test!(PackageFiles|Startup).js"]
}
5 changes: 5 additions & 0 deletions test/package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const path = require('path');
const { tests } = require('@iobroker/testing');

// Validate the package files
tests.packageFiles(path.join(__dirname, '..'));
7 changes: 7 additions & 0 deletions test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"noImplicitAny": false
},
"include": ["./**/*.js"]
}

0 comments on commit b8758d8

Please sign in to comment.