Simplify test commands in package.json

The supervisor used to perform tests both for the transpiled code (after
tsc) and one for the typescript code (using
ts-node/register/transpile-only). There is not really a reason for this
and this added complexity to the test configuration. This used to make
testing harder, as the built code didn't include source maps, meaning
the tests did not point to the right code.

Since we want to split tests in unit and integration tests as the next
test improvement, it makes sense to simplify these commands before
adding more complexity.

Change-type: patch
This commit is contained in:
Felipe Lalanne 2022-08-17 15:26:49 -04:00
parent d83a37e6fd
commit 274503feb3
4 changed files with 140 additions and 157 deletions

View File

@ -96,13 +96,13 @@ COPY --from=build-base /usr/src/app/node_modules ./node_modules
# Copy build files # Copy build files
COPY build-utils ./build-utils COPY build-utils ./build-utils
COPY webpack.config.js tsconfig.json tsconfig.release.json ./ COPY webpack.config.js tsconfig.json tsconfig.release.json tsconfig.js.json ./
COPY src ./src COPY src ./src
COPY test ./test COPY test ./test
COPY typings ./typings COPY typings ./typings
# Run the tests # Run the tests
RUN npm run test-nolint RUN npm run test
################################################### ###################################################
# Build the production package # Build the production package

View File

@ -1,143 +1,137 @@
{ {
"name": "balena-supervisor", "name": "balena-supervisor",
"description": "This is balena's Supervisor, a program that runs on IoT devices and has the task of running user Apps (which are Docker containers), and updating them as the balena API informs it to.", "description": "This is balena's Supervisor, a program that runs on IoT devices and has the task of running user Apps (which are Docker containers), and updating them as the balena API informs it to.",
"version": "14.0.13", "version": "14.0.13",
"license": "Apache-2.0", "license": "Apache-2.0",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/balena-os/balena-supervisor.git" "url": "https://github.com/balena-os/balena-supervisor.git"
}, },
"scripts": { "scripts": {
"start": "./entry.sh", "start": "./entry.sh",
"build": "npm run release && webpack", "build": "npm run clean && npm run release && webpack",
"build:debug": "npm run release && npm run packagejson:copy", "lint": "balena-lint -e ts -e js --typescript src/ test/ typings/ build-utils/ webpack.config.js",
"lint": "balena-lint -e ts -e js --typescript src/ test/ typings/ build-utils/ webpack.config.js && tsc --noEmit && tsc --noEmit --project tsconfig.js.json", "test:build": "tsc --noEmit && tsc --noEmit --project tsconfig.js.json",
"test": "npm run clean && npm run test-nolint", "test:node": "mocha --config test/.mocharc.js",
"posttest": "npm run lint", "test": "npm run lint && npm run test:build && npm run test:node",
"test-nolint": "npm run test:build && TEST=1 mocha --config test/.mocharc.js", "test:fast": "npm run test:build && npm run test:node",
"test:build": "npm run test-build && npm run testitems:copy && npm run packagejson:copy", "prettify": "balena-lint -e ts -e js --typescript --fix src/ test/ typings/ build-utils/ webpack.config.js",
"test:fast": "TEST=1 mocha --config test/.mocharc.fast.js", "release": "tsc --project tsconfig.release.json && mv build/src/* build",
"test:debug": "npm run test:build && TEST=1 mocha --inspect-brk --config test/.mocharc.js", "sync": "ts-node --files sync/sync.ts",
"prettify": "balena-lint -e ts -e js --typescript --fix src/ test/ typings/ build-utils/ webpack.config.js", "clean": "rimraf build"
"test-build": "tsc --project tsconfig.json", },
"release": "tsc --project tsconfig.release.json && mv build/src/* build", "private": true,
"packagejson:copy": "cp package.json build/", "dependencies": {
"testitems:copy": "cp -r test/data build/test/", "@balena/happy-eyeballs": "0.0.6",
"sync": "ts-node --files sync/sync.ts", "dbus": "^1.0.7",
"clean": "rimraf build" "mdns-resolver": "^1.0.0",
}, "semver": "^7.3.2",
"private": true, "sinon": "^11.1.2",
"dependencies": { "sqlite3": "^4.1.1",
"@balena/happy-eyeballs": "0.0.6", "systeminformation": "^5.6.10"
"dbus": "^1.0.7", },
"mdns-resolver": "^1.0.0", "engines": {
"semver": "^7.3.2", "node": "^12.16.2",
"sinon": "^11.1.2", "npm": "^6.14.4"
"sqlite3": "^4.1.1", },
"systeminformation": "^5.6.10" "devDependencies": {
}, "@balena/contrato": "^0.6.0",
"engines": { "@balena/lint": "^5.1.0",
"node": "^12.16.2", "@types/bluebird": "^3.5.32",
"npm": "^6.14.4" "@types/chai": "^4.2.16",
}, "@types/chai-as-promised": "^7.1.3",
"devDependencies": { "@types/chai-like": "^1.1.0",
"@balena/contrato": "^0.6.0", "@types/chai-things": "0.0.34",
"@balena/lint": "^5.1.0", "@types/common-tags": "^1.8.0",
"@types/bluebird": "^3.5.32", "@types/copy-webpack-plugin": "^6.0.0",
"@types/chai": "^4.2.16", "@types/dbus": "^1.0.0",
"@types/chai-as-promised": "^7.1.3", "@types/dockerode": "^2.5.34",
"@types/chai-like": "^1.1.0", "@types/event-stream": "^3.3.34",
"@types/chai-things": "0.0.34", "@types/express": "^4.17.3",
"@types/common-tags": "^1.8.0", "@types/lodash": "^4.14.159",
"@types/copy-webpack-plugin": "^6.0.0", "@types/memoizee": "^0.4.4",
"@types/dbus": "^1.0.0", "@types/mocha": "^8.2.2",
"@types/dockerode": "^2.5.34", "@types/mock-fs": "^4.13.0",
"@types/event-stream": "^3.3.34", "@types/morgan": "^1.9.0",
"@types/express": "^4.17.3", "@types/node": "^12.12.54",
"@types/lodash": "^4.14.159", "@types/request": "^2.48.5",
"@types/memoizee": "^0.4.4", "@types/rewire": "^2.5.28",
"@types/mocha": "^8.2.2", "@types/rimraf": "^2.0.4",
"@types/mock-fs": "^4.13.0", "@types/rwlock": "^5.0.2",
"@types/morgan": "^1.9.0", "@types/semver": "^7.3.3",
"@types/node": "^12.12.54", "@types/shell-quote": "^1.7.0",
"@types/request": "^2.48.5", "@types/sinon": "^10.0.11",
"@types/rewire": "^2.5.28", "@types/sinon-chai": "^3.2.5",
"@types/rimraf": "^2.0.4", "@types/supertest": "^2.0.11",
"@types/rwlock": "^5.0.2", "@types/terser-webpack-plugin": "^3.0.0",
"@types/semver": "^7.3.3", "@types/tmp": "^0.1.0",
"@types/shell-quote": "^1.7.0", "@types/webpack": "^4.41.21",
"@types/sinon": "^10.0.11", "@types/yargs": "^15.0.12",
"@types/sinon-chai": "^3.2.5", "balena-register-device": "^7.2.0",
"@types/supertest": "^2.0.11", "blinking": "^0.0.4",
"@types/terser-webpack-plugin": "^3.0.0", "bluebird": "^3.7.2",
"@types/tmp": "^0.1.0", "chai": "^4.3.4",
"@types/webpack": "^4.41.21", "chai-as-promised": "^7.1.1",
"@types/yargs": "^15.0.12", "chai-like": "^1.1.1",
"balena-register-device": "^7.2.0", "chai-things": "^0.2.0",
"blinking": "^0.0.4", "chokidar": "^3.5.1",
"bluebird": "^3.7.2", "common-tags": "^1.8.0",
"chai": "^4.3.4", "copy-webpack-plugin": "^6.0.3",
"chai-as-promised": "^7.1.1", "deep-object-diff": "^1.1.0",
"chai-like": "^1.1.1", "docker-delta": "^2.2.11",
"chai-things": "^0.2.0", "docker-progress": "^4.0.3",
"chokidar": "^3.5.1", "dockerode": "^2.5.8",
"common-tags": "^1.8.0", "duration-js": "^4.0.0",
"copy-webpack-plugin": "^6.0.3", "event-stream": "3.3.4",
"deep-object-diff": "^1.1.0", "express": "^4.17.1",
"docker-delta": "^2.2.11", "fork-ts-checker-webpack-plugin": "^5.1.0",
"docker-progress": "^4.0.3", "fp-ts": "^2.8.1",
"dockerode": "^2.5.8", "husky": "^4.2.5",
"duration-js": "^4.0.0", "io-ts": "^2.2.10",
"event-stream": "3.3.4", "io-ts-reporters": "^1.2.2",
"express": "^4.17.1", "json-mask": "^0.3.9",
"fork-ts-checker-webpack-plugin": "^5.1.0", "knex": "^0.20.13",
"fp-ts": "^2.8.1", "lint-staged": "^10.2.11",
"husky": "^4.2.5", "livepush": "^3.5.1",
"io-ts": "^2.2.10", "lodash": "^4.17.21",
"io-ts-reporters": "^1.2.2", "memoizee": "^0.4.14",
"json-mask": "^0.3.9", "mixpanel": "^0.10.3",
"knex": "^0.20.13", "mocha": "^8.3.2",
"lint-staged": "^10.2.11", "mock-fs": "^4.14.0",
"livepush": "^3.5.1", "morgan": "^1.10.0",
"lodash": "^4.17.21", "network-checker": "^0.1.1",
"memoizee": "^0.4.14", "nock": "^13.1.2",
"mixpanel": "^0.10.3", "nodemon": "^2.0.4",
"mocha": "^8.3.2", "pinejs-client-request": "^7.2.1",
"mock-fs": "^4.14.0", "pretty-ms": "^7.0.1",
"morgan": "^1.10.0", "request": "^2.88.2",
"network-checker": "^0.1.1", "resin-docker-build": "^1.1.6",
"nock": "^13.1.2", "resumable-request": "^2.0.1",
"nodemon": "^2.0.4", "rewire": "^5.0.0",
"pinejs-client-request": "^7.2.1", "rimraf": "^2.7.1",
"pretty-ms": "^7.0.1", "rwlock": "^5.0.0",
"request": "^2.88.2", "shell-quote": "^1.7.2",
"resin-docker-build": "^1.1.6", "sinon-chai": "^3.6.0",
"resumable-request": "^2.0.1", "strict-event-emitter-types": "^2.0.0",
"rewire": "^5.0.0", "supertest": "^6.1.3",
"rimraf": "^2.7.1", "tar-stream": "^2.1.3",
"rwlock": "^5.0.0", "terser-webpack-plugin": "^4.1.0",
"shell-quote": "^1.7.2", "tmp": "^0.1.0",
"sinon-chai": "^3.6.0", "ts-loader": "^7.0.5",
"strict-event-emitter-types": "^2.0.0", "ts-node": "^8.10.2",
"supertest": "^6.1.3", "typed-error": "^3.2.1",
"tar-stream": "^2.1.3", "typescript": "^4.2.4",
"terser-webpack-plugin": "^4.1.0", "webpack": "^4.44.1",
"tmp": "^0.1.0", "webpack-cli": "^3.3.12",
"ts-loader": "^7.0.5", "winston": "^3.3.3",
"ts-node": "^8.10.2", "yargs": "^15.4.1"
"typed-error": "^3.2.1", },
"typescript": "^4.2.4", "husky": {
"webpack": "^4.44.1", "hooks": {
"webpack-cli": "^3.3.12", "pre-commit": "lint-staged"
"winston": "^3.3.3", }
"yargs": "^15.4.1" },
}, "versionist": {
"husky": { "publishedAt": "2022-08-02T21:43:16.303Z"
"hooks": { }
"pre-commit": "lint-staged"
}
},
"versionist": {
"publishedAt": "2022-08-02T21:43:16.303Z"
}
} }

View File

@ -1,12 +0,0 @@
module.exports = {
bail: true, // Exit test script on first error
exit: true, // Force Mocha to exit after tests complete
recursive: true, // Look for tests in subdirectories
require: [
// Files to execute before running suites
'ts-node/register/transpile-only',
'test/config/fixtures.ts',
],
spec: ['test/**/*.spec.ts'],
timeout: '30000',
};

View File

@ -4,8 +4,9 @@ module.exports = {
recursive: true, // Look for tests in subdirectories recursive: true, // Look for tests in subdirectories
require: [ require: [
// Files to execute before running suites // Files to execute before running suites
'build/test/config/fixtures.js', 'ts-node/register/transpile-only',
'test/config/fixtures.ts',
], ],
spec: ['build/test/**/*.spec.js'], spec: ['test/**/*.spec.ts'],
timeout: '30000', timeout: '30000',
}; };