From 251135d684f6e84911898895acb7c92b544b4af0 Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Sat, 6 Apr 2019 15:40:03 -0500 Subject: [PATCH] tests(image-cli): migrate to jest --- .travis.yml | 6 +++--- jest.config.js | 3 ++- package.json | 5 +---- packages/image-cli/jest.config.js | 1 + packages/image-cli/package.json | 9 ++------- packages/image/package.json | 15 ++------------- 6 files changed, 11 insertions(+), 28 deletions(-) create mode 100644 packages/image-cli/jest.config.js diff --git a/.travis.yml b/.travis.yml index 79137bb..3122b55 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,9 +36,9 @@ jobs: script: - npm run build - npm run test:lint - - npm run test:coverage - - npm install -g coveralls nyc - - nyc report --reporter=text-lcov | coveralls || echo 'Failed to upload to coveralls...' + - npm run test:unit -- --coverage --runInBand --verbose + - npm install -g coveralls + - cat coverage/lcov.info | coveralls || echo 'Failed to upload to coveralls...' - stage: deploy os: linux dist: trusty diff --git a/jest.config.js b/jest.config.js index 83c8dbb..089297e 100644 --- a/jest.config.js +++ b/jest.config.js @@ -11,7 +11,8 @@ module.exports = { '\\.ts$': 'ts-jest', }, moduleFileExtensions: ['ts', 'js', 'json'], + setupFilesAfterEnv: ['./packages/image/test/utils.js'], transformIgnorePatterns: ['/node_modules/(?!@tensorflow).*/'], testPathIgnorePatterns: ['/node_modules/', 'shared-image.test.ts'], - testMatch: ['**/exif/**/*.test.js', '**/image/**/*.test.js', '**/image/**/*.test.ts'], + testMatch: ['**/*.test.js', '**/*.test.ts'], } diff --git a/package.json b/package.json index 37433e7..e269ef2 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "build:watch": "lerna exec --parallel 'tsc -w'", "test": "npm run build && npm run test:lint && npm run test:unit", "test:lint": "lint", - "test:unit": "mocha --require source-map-support/register --timeout 20000 'packages/*/test/**/*.test.js'", + "test:unit": "jest", "test:coverage": "nyc npm run test:unit" }, "devDependencies": { @@ -18,9 +18,6 @@ "@types/jest": "^24.0.11", "jest": "^24.7.1", "lerna": "^3.10.7", - "mocha": "^5.2.0", - "nyc": "^12.0.1", - "source-map-support": "^0.5.6", "ts-jest": "^24.0.2", "tslint": "^5.11.0", "typescript": "^3.3.1" diff --git a/packages/image-cli/jest.config.js b/packages/image-cli/jest.config.js new file mode 100644 index 0000000..50200e3 --- /dev/null +++ b/packages/image-cli/jest.config.js @@ -0,0 +1 @@ +module.exports = require('../../jest.config') diff --git a/packages/image-cli/package.json b/packages/image-cli/package.json index d09ca25..7018e09 100644 --- a/packages/image-cli/package.json +++ b/packages/image-cli/package.json @@ -11,10 +11,9 @@ "download-prebuilt": "./scripts/download-prebuilt.sh", "build": "tsc && bash ./scripts/build.sh", "test": "npm run test:lint && npm run test:unit", - "test:unit": "mocha --reporter spec --timeout 4000 'test/**/*.test.js'", + "test:unit": "jest", "test:lint": "lint", - "test:coverage": "nyc npm run test:unit", - "test:watch": "mocha --watch --reporter dot 'test/**/*.test.js'" + "test:watch": "jest --watch" }, "publishConfig": { "access": "public" @@ -40,12 +39,8 @@ "@eris/image": "^0.1.0-development", "chai": "^4.1.2", "chai-as-promised": "^7.1.1", - "cz-conventional-changelog": "^2.0.0", "execa": "^0.8.0", - "mocha": "^4.0.1", - "nyc": "^11.2.1", "pkg": "^4.3.7", - "semantic-release": "^8.0.3", "sinon": "^4.0.1", "sinon-chai": "^2.14.0" }, diff --git a/packages/image/package.json b/packages/image/package.json index 300216c..3977a16 100644 --- a/packages/image/package.json +++ b/packages/image/package.json @@ -11,15 +11,10 @@ "build:rollup": "rollup -c rollup.config.js && cp dist/bundle.js demo/ && cp dist/browser-index.d.ts dist/bundle.d.ts", "build:rollup:minify": "cross-env MINIFY=true rollup -c rollup.config.js && cp dist/bundle.min.js demo/", "test": "npm run test:lint && npm run test:unit", - "test:unit": "mocha --require source-map-support/register --timeout 20000 --reporter spec --recursive ./test", + "test:unit": "jest", "test:lint": "lint", "test:update-expectations": "cross-env UPDATE_EXPECTATIONS=true npm run test:unit", - "test:upload": "bash test/fixtures/upload.sh", - "test:update-all": "npm run test:update-expectations && npm run test:upload", - "test:download": "bash test/fixtures/download.sh", - "test:coverage": "nyc npm run test:unit", - "test:watch": "mocha --watch --reporter dot 'test/**/*.test.js'", - "semantic-release": "semantic-release pre && npm publish --access public && semantic-release post" + "test:watch": "jest --watch" }, "publishConfig": { "access": "public" @@ -51,21 +46,15 @@ "babili": "^0.1.2", "chai": "^3.5.0", "cross-env": "^5.1.0", - "cz-conventional-changelog": "^2.0.0", - "istanbul": "^0.4.5", "lodash": "^4.17.4", - "mocha": "^3.3.0", - "nyc": "^10.3.2", "rollup": "^0.41.6", "rollup-plugin-alias": "^1.3.1", "rollup-plugin-babili": "^3.0.0", "rollup-plugin-commonjs": "^8.0.2", "rollup-plugin-node-resolve": "^3.0.0", "rollup-plugin-sourcemaps": "^0.4.2", - "semantic-release": "^6.3.2", "sinon": "^2.1.0", "sinon-chai": "^2.9.0", - "source-map-support": "^0.4.15", "tslint": "^5.2.0", "typescript": "^3.3.1" },