From 6bba9eb62027478b2ac15fb7f3b4fc5a792e843c Mon Sep 17 00:00:00 2001 From: Bowen Tan Date: Tue, 7 Sep 2021 17:25:17 +0800 Subject: [PATCH] fix jest test --- config/jest.config.js | 8 -- packages/core/babel.config.js | 7 ++ packages/core/package.json | 1 - packages/runtime/babel.config.js | 1 + packages/runtime/jest.config.js | 193 +------------------------------ yarn.lock | 70 ++++------- 6 files changed, 30 insertions(+), 250 deletions(-) create mode 100644 packages/core/babel.config.js diff --git a/config/jest.config.js b/config/jest.config.js index 6f8a4895..b309dc48 100644 --- a/config/jest.config.js +++ b/config/jest.config.js @@ -1,12 +1,4 @@ module.exports = { - transform: { - ".ts": "ts-jest", - }, - globals: { - "ts-jest": { - diagnostics: false, - }, - }, moduleFileExtensions: ["ts", "js"], testMatch: ["/__tests__/**/**.spec.ts"], testPathIgnorePatterns: ["/node_modules/", "/lib/", "/lib/"], diff --git a/packages/core/babel.config.js b/packages/core/babel.config.js new file mode 100644 index 00000000..be22fda2 --- /dev/null +++ b/packages/core/babel.config.js @@ -0,0 +1,7 @@ +// only for jest +module.exports = { + presets: [ + ['@babel/preset-env', { targets: { node: 'current' } }], + '@babel/preset-typescript', + ], +}; diff --git a/packages/core/package.json b/packages/core/package.json index ef496b0f..7f8903f9 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -36,7 +36,6 @@ "eslint-config-prettier": "^8.3.0", "jest": "^27.0.6", "prettier": "^2.3.2", - "ts-jest": "^27.0.3", "typescript": "^4.3.5" }, "dependencies": { diff --git a/packages/runtime/babel.config.js b/packages/runtime/babel.config.js index 8165fe45..be22fda2 100644 --- a/packages/runtime/babel.config.js +++ b/packages/runtime/babel.config.js @@ -1,3 +1,4 @@ +// only for jest module.exports = { presets: [ ['@babel/preset-env', { targets: { node: 'current' } }], diff --git a/packages/runtime/jest.config.js b/packages/runtime/jest.config.js index d3124778..35fcb1b3 100644 --- a/packages/runtime/jest.config.js +++ b/packages/runtime/jest.config.js @@ -1,194 +1,3 @@ -/* - * For a detailed explanation regarding each configuration property, visit: - * https://jestjs.io/docs/configuration - */ - module.exports = { - // All imported modules in your tests should be mocked automatically - // automock: false, - - // Stop running tests after `n` failures - // bail: 0, - - // The directory where Jest should store its cached dependency information - // cacheDirectory: "/private/var/folders/kw/2bg888cn45ngf25_k99fqmtr0000gn/T/jest_dx", - - // Automatically clear mock calls and instances between every test - // clearMocks: false, - - // Indicates whether the coverage information should be collected while executing the test - // collectCoverage: false, - - // An array of glob patterns indicating a set of files for which coverage information should be collected - // collectCoverageFrom: undefined, - - // The directory where Jest should output its coverage files - // coverageDirectory: undefined, - - // An array of regexp pattern strings used to skip coverage collection - // coveragePathIgnorePatterns: [ - // "/node_modules/" - // ], - - // Indicates which provider should be used to instrument code for coverage - coverageProvider: "v8", - - // A list of reporter names that Jest uses when writing coverage reports - // coverageReporters: [ - // "json", - // "text", - // "lcov", - // "clover" - // ], - - // An object that configures minimum threshold enforcement for coverage results - // coverageThreshold: undefined, - - // A path to a custom dependency extractor - // dependencyExtractor: undefined, - - // Make calling deprecated APIs throw helpful error messages - // errorOnDeprecated: false, - - // Force coverage collection from ignored files using an array of glob patterns - // forceCoverageMatch: [], - - // A path to a module which exports an async function that is triggered once before all test suites - // globalSetup: undefined, - - // A path to a module which exports an async function that is triggered once after all test suites - // globalTeardown: undefined, - - // A set of global variables that need to be available in all test environments - // globals: {}, - - // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers. - // maxWorkers: "50%", - - // An array of directory names to be searched recursively up from the requiring module's location - // moduleDirectories: [ - // "node_modules" - // ], - - // An array of file extensions your modules use - // moduleFileExtensions: [ - // "js", - // "jsx", - // "ts", - // "tsx", - // "json", - // "node" - // ], - - // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module - // moduleNameMapper: {}, - - // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader - // modulePathIgnorePatterns: [], - - // Activates notifications for test results - // notify: false, - - // An enum that specifies notification mode. Requires { notify: true } - // notifyMode: "failure-change", - - // A preset that is used as a base for Jest's configuration - // preset: undefined, - - // Run tests from one or more projects - // projects: undefined, - - // Use this configuration option to add custom reporters to Jest - // reporters: undefined, - - // Automatically reset mock state between every test - // resetMocks: false, - - // Reset the module registry before running each individual test - // resetModules: false, - - // A path to a custom resolver - // resolver: undefined, - - // Automatically restore mock state between every test - // restoreMocks: false, - - // The root directory that Jest should scan for tests and modules within - // rootDir: undefined, - - // A list of paths to directories that Jest should use to search for files in - // roots: [ - // "" - // ], - - // Allows you to use a custom runner instead of Jest's default test runner - // runner: "jest-runner", - - // The paths to modules that run some code to configure or set up the testing environment before each test - // setupFiles: [], - - // A list of paths to modules that run some code to configure or set up the testing framework before each test - // setupFilesAfterEnv: [], - - // The number of seconds after which a test is considered as slow and reported as such in the results. - // slowTestThreshold: 5, - - // A list of paths to snapshot serializer modules Jest should use for snapshot testing - // snapshotSerializers: [], - - // The test environment that will be used for testing - testEnvironment: "jsdom", - - // Options that will be passed to the testEnvironment - // testEnvironmentOptions: {}, - - // Adds a location field to test results - // testLocationInResults: false, - - // The glob patterns Jest uses to detect test files - // testMatch: [ - // "**/__tests__/**/*.[jt]s?(x)", - // "**/?(*.)+(spec|test).[tj]s?(x)" - // ], - - // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped - // testPathIgnorePatterns: [ - // "/node_modules/" - // ], - - // The regexp pattern or array of patterns that Jest uses to detect test files - // testRegex: [], - - // This option allows the use of a custom results processor - // testResultsProcessor: undefined, - - // This option allows use of a custom test runner - // testRunner: "jest-circus/runner", - - // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href - // testURL: "http://localhost", - - // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout" - // timers: "real", - - // A map from regular expressions to paths to transformers - // transform: undefined, - - // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation - // transformIgnorePatterns: [ - // "/node_modules/", - // "\\.pnp\\.[^\\/]+$" - // ], - - // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them - // unmockedModulePathPatterns: undefined, - - // Indicates whether each individual test should be reported during the run - // verbose: undefined, - - // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode - // watchPathIgnorePatterns: [], - - // Whether to use watchman for file crawling - // watchman: true, + ...require("../../config/jest.config"), }; diff --git a/yarn.lock b/yarn.lock index ad5867cc..042c9cf6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3804,13 +3804,6 @@ browserslist@^4.16.8: escalade "^3.1.1" node-releases "^1.1.75" -bs-logger@0.x: - version "0.2.6" - resolved "http://192.168.26.29:7001/bs-logger/download/bs-logger-0.2.6.tgz#eb7d365307a72cf974cc6cda76b68354ad336bd8" - integrity sha1-6302UwenLPl0zGzadraDVK0za9g= - dependencies: - fast-json-stable-stringify "2.x" - bser@2.1.1: version "2.1.1" resolved "http://192.168.26.29:7001/bser/download/bser-2.1.1.tgz#e6787da20ece9d07998533cfd9de6f5c38f4bc05" @@ -3818,7 +3811,7 @@ bser@2.1.1: dependencies: node-int64 "^0.4.0" -buffer-from@1.x, buffer-from@^1.0.0: +buffer-from@^1.0.0: version "1.1.1" resolved "http://192.168.26.29:7001/buffer-from/download/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" integrity sha1-MnE7wCj3XAL9txDXx7zsHyxgcO8= @@ -4865,7 +4858,7 @@ fast-glob@^3.1.1: merge2 "^1.3.0" micromatch "^4.0.4" -fast-json-stable-stringify@2.x, fast-json-stable-stringify@^2.0.0: +fast-json-stable-stringify@^2.0.0: version "2.1.0" resolved "http://192.168.26.29:7001/fast-json-stable-stringify/download/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" integrity sha1-h0v2nG9ATCtdmcSBNBOZ/VWJJjM= @@ -6467,7 +6460,7 @@ jest-snapshot@^27.1.0: pretty-format "^27.1.0" semver "^7.3.2" -jest-util@^27.0.0, jest-util@^27.0.6: +jest-util@^27.0.6: version "27.0.6" resolved "http://192.168.26.29:7001/jest-util/download/jest-util-27.0.6.tgz#e8e04eec159de2f4d5f57f795df9cdc091e50297" integrity sha1-6OBO7BWd4vTV9X95XfnNwJHlApc= @@ -6673,7 +6666,7 @@ json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1: resolved "http://192.168.26.29:7001/json-stringify-safe/download/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= -json5@2.x, json5@^2.1.2: +json5@^2.1.2: version "2.2.0" resolved "http://192.168.26.29:7001/json5/download/json5-2.2.0.tgz#2dfefe720c6ba525d9ebd909950f0515316c89a3" integrity sha1-Lf7+cgxrpSXZ69kJlQ8FFTFsiaM= @@ -6909,7 +6902,7 @@ lodash.truncate@^4.4.2: resolved "http://192.168.26.29:7001/lodash.truncate/download/lodash.truncate-4.4.2.tgz#5a350da0b1113b837ecfffd5812cbe58d6eae193" integrity sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM= -lodash@4.x, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.21, lodash@^4.7.0: +lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.21, lodash@^4.7.0: version "4.17.21" resolved "http://192.168.26.29:7001/lodash/download/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha1-Z5WRxWTDv/quhFTPCz3zcMPWkRw= @@ -6961,11 +6954,6 @@ make-dir@^3.0.0: dependencies: semver "^6.0.0" -make-error@1.x: - version "1.3.6" - resolved "http://192.168.26.29:7001/make-error/download/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" - integrity sha1-LrLjfqm2fEiR9oShOUeZr0hM96I= - make-fetch-happen@^8.0.9: version "8.0.14" resolved "http://192.168.26.29:7001/make-fetch-happen/download/make-fetch-happen-8.0.14.tgz#aaba73ae0ab5586ad8eaa68bd83332669393e222" @@ -7262,11 +7250,6 @@ mkdirp-infer-owner@^2.0.0: infer-owner "^1.0.4" mkdirp "^1.0.3" -mkdirp@1.x, mkdirp@^1.0.3, mkdirp@^1.0.4: - version "1.0.4" - resolved "http://192.168.26.29:7001/mkdirp/download/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" - integrity sha1-PrXtYmInVteaXw4qIh3+utdcL34= - mkdirp@^0.5.0, mkdirp@^0.5.1: version "0.5.5" resolved "http://192.168.26.29:7001/mkdirp/download/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" @@ -7274,6 +7257,11 @@ mkdirp@^0.5.0, mkdirp@^0.5.1: dependencies: minimist "^1.2.5" +mkdirp@^1.0.3, mkdirp@^1.0.4: + version "1.0.4" + resolved "http://192.168.26.29:7001/mkdirp/download/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" + integrity sha1-PrXtYmInVteaXw4qIh3+utdcL34= + modify-values@^1.0.0: version "1.0.1" resolved "http://192.168.26.29:7001/modify-values/download/modify-values-1.0.1.tgz#b3939fa605546474e3e3e3c63d64bd43b4ee6022" @@ -8581,18 +8569,18 @@ semver@7.0.0: resolved "http://192.168.26.29:7001/semver/download/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e" integrity sha1-XzyjV2HkfgWyBsba/yz4FPAxa44= -semver@7.x, semver@^7.1.1, semver@^7.1.3, semver@^7.2.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5: +semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.3.0: + version "6.3.0" + resolved "http://192.168.26.29:7001/semver/download/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" + integrity sha1-7gpkyK9ejO6mdoexM3YeG+y9HT0= + +semver@^7.1.1, semver@^7.1.3, semver@^7.2.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5: version "7.3.5" resolved "http://192.168.26.29:7001/semver/download/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7" integrity sha1-C2Ich5NI2JmOSw5L6Us/EuYBjvc= dependencies: lru-cache "^6.0.0" -semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.3.0: - version "6.3.0" - resolved "http://192.168.26.29:7001/semver/download/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" - integrity sha1-7gpkyK9ejO6mdoexM3YeG+y9HT0= - set-blocking@~2.0.0: version "2.0.0" resolved "http://192.168.26.29:7001/set-blocking/download/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" @@ -9189,22 +9177,6 @@ trough@^1.0.0: resolved "http://192.168.26.29:7001/trough/download/trough-1.0.5.tgz#b8b639cefad7d0bb2abd37d433ff8293efa5f406" integrity sha1-uLY5zvrX0LsqvTfUM/+Ck++l9AY= -ts-jest@^27.0.3: - version "27.0.3" - resolved "http://192.168.26.29:7001/ts-jest/download/ts-jest-27.0.3.tgz#808492f022296cde19390bb6ad627c8126bf93f8" - integrity sha1-gISS8CIpbN4ZOQu2rWJ8gSa/k/g= - dependencies: - bs-logger "0.x" - buffer-from "1.x" - fast-json-stable-stringify "2.x" - jest-util "^27.0.0" - json5 "2.x" - lodash "4.x" - make-error "1.x" - mkdirp "1.x" - semver "7.x" - yargs-parser "20.x" - tslib@^1.0.0, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3: version "1.14.1" resolved "http://192.168.26.29:7001/tslib/download/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" @@ -9781,11 +9753,6 @@ yargs-parser@20.2.4: resolved "http://192.168.26.29:7001/yargs-parser/download/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" integrity sha1-tCiQ8UVmeW+Fro46JSkNIF8VSlQ= -yargs-parser@20.x, yargs-parser@^20.2.2, yargs-parser@^20.2.3: - version "20.2.9" - resolved "http://192.168.26.29:7001/yargs-parser/download/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" - integrity sha1-LrfcOwKJcY/ClfNidThFxBoMlO4= - yargs-parser@^18.1.3: version "18.1.3" resolved "http://192.168.26.29:7001/yargs-parser/download/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0" @@ -9794,6 +9761,11 @@ yargs-parser@^18.1.3: camelcase "^5.0.0" decamelize "^1.2.0" +yargs-parser@^20.2.2, yargs-parser@^20.2.3: + version "20.2.9" + resolved "http://192.168.26.29:7001/yargs-parser/download/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" + integrity sha1-LrfcOwKJcY/ClfNidThFxBoMlO4= + yargs@^16.0.3, yargs@^16.2.0: version "16.2.0" resolved "http://192.168.26.29:7001/yargs/download/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66"