From 52f56ab9b0ac4912edd0516aa5317c10250bc96a Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 19 Mar 2020 11:28:07 +0100 Subject: [PATCH 1/2] packages: use cli to test and lint core and cli --- packages/cli/package.json | 4 ++-- packages/core/package.json | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index 48aaa0dd73..7612ab1c35 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -7,8 +7,8 @@ "scripts": { "exec": "npx ts-node ./src", "build": "tsc --outDir dist --noEmit false --module CommonJS", - "lint": "web-scripts lint", - "test": "web-scripts test", + "lint": "backstage-cli lint", + "test": "backstage-cli test", "start": "nodemon ." }, "devDependencies": { diff --git a/packages/core/package.json b/packages/core/package.json index ba4186339a..b6ceeb42f2 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -7,11 +7,10 @@ "types": "dist/cjs/index.d.ts", "scripts": { "build": "tsc --outDir dist/cjs --noEmit false --module CommonJS", - "lint": "web-scripts lint", - "test": "web-scripts test" + "lint": "backstage-cli lint", + "test": "backstage-cli test" }, "dependencies": { - "@spotify-backstage/cli": "^0.1.0", "@material-ui/core": "^4.9.1", "@material-ui/icons": "^4.9.1", "@types/google-protobuf": "^3.7.2", @@ -27,7 +26,7 @@ "recompose": "0.30.0" }, "devDependencies": { - "@spotify/web-scripts": "^6.0.0", + "@spotify-backstage/cli": "^0.1.0", "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.3.2", "@testing-library/user-event": "^7.1.2", From bd801756eb62803dd705aebf6deba14d196cce2a Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 19 Mar 2020 12:08:09 +0100 Subject: [PATCH 2/2] cli: support ts jest config and make test setup module optional --- packages/cli/config/jest.js | 12 ++++++++++-- packages/core/{jest.config.js => jest.config.ts} | 0 2 files changed, 10 insertions(+), 2 deletions(-) rename packages/core/{jest.config.js => jest.config.ts} (100%) diff --git a/packages/cli/config/jest.js b/packages/cli/config/jest.js index d849bf307f..e443ceec1b 100644 --- a/packages/cli/config/jest.js +++ b/packages/cli/config/jest.js @@ -21,14 +21,22 @@ const path = require('path'); // manually extend @spotify/web-scripts/config/jest.config.js that is desired if (fs.existsSync('jest.config.js')) { module.exports = require(path.resolve('jest.config.js')); +} else if (fs.existsSync('jest.config.ts')) { + module.exports = require(path.resolve('jest.config.ts')); } else { + const extraOptions = {}; + + // Use src/setupTests.ts as the default location for configuring test env + if (fs.existsSync('src/setupTests.ts')) { + extraOptions.setupFilesAfterEnv = ['/setupTests.ts']; + } + module.exports = { // We base the jest config on web-scripts, it's pretty flat so we skip any complex merging of config objects // Config can be found here: https://github.com/spotify/web-scripts/blob/master/packages/web-scripts/config/jest.config.js ...require('@spotify/web-scripts/config/jest.config.js'), - // Use src/setupTests.ts as the default location for configuring test env - setupFilesAfterEnv: ['/setupTests.ts'], + ...extraOptions, // If the package has a jest object in package.json we merge that config in. This is the recommended // location for configuring tests. diff --git a/packages/core/jest.config.js b/packages/core/jest.config.ts similarity index 100% rename from packages/core/jest.config.js rename to packages/core/jest.config.ts