diff --git a/jest.config.js b/jest.config.js index b33c151fd2df6c5239ba4fb6a02ce1f154e18a8f..fd80b0b92790de6dd52a7f7d4464e5e6addb02b5 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,10 +1,4 @@ -// 自动化测试 - -// 备注: -// -// 1. testPathIgnorePatterns 忽略/pages/API的几条用例,是因为在ios设备上,运行会导致app崩溃。后期完成后,再去除。 -// 2. testPathIgnorePatterns 忽略webview相关用例, 是因为采用app-webview方式后,不需要这两个用例。请勿修改和提交到Git。 -// +const path = require('path') module.exports = { testTimeout: 30000, @@ -15,8 +9,7 @@ module.exports = { testMatch: ["/pages/**/*test.[jt]s?(x)"], testPathIgnorePatterns: [ '/node_modules/', - '/pages/webview-screenshot-comparison/webview-screenshot-comparison.test.js', - '/pages/webview-screenshot/webview-screenshot.test.js' ], setupFilesAfterEnv: ['/jest-setup.js'], + testSequencer: path.join(__dirname, "testSequencer.js") } diff --git a/testSequencer.js b/testSequencer.js new file mode 100644 index 0000000000000000000000000000000000000000..ff7368f7eaa6e51bd24d5e96d35450be370d9b18 --- /dev/null +++ b/testSequencer.js @@ -0,0 +1,15 @@ +const Sequencer = require("@jest/test-sequencer").default +const sortTestFilePaths = ["/pages/API/pull-down-refresh/pull-down-refresh.test.js"] +class CustomSequencer extends Sequencer { + sort(tests) { + // 测试例排序 + const sortedTests = sortTestFilePaths + .map((filePath) => { + return tests.find((test) => test.path.endsWith(filePath)) + }) + .filter(Boolean) + return [...new Set([...sortedTests, ...tests])] + } +} + +module.exports = CustomSequencer