From 57c5bc5f25f6acc5d910181d08b729f78fdef8df Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Wed, 3 Jul 2024 16:44:37 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E9=80=9A=E8=BF=87=E9=99=90=E5=88=B6?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E9=A1=BA=E5=BA=8F=EF=BC=8C=E8=A7=84=E9=81=BF?= =?UTF-8?q?=20pullDownRefresh=20=E6=B5=8B=E8=AF=95=E6=89=8B=E5=8A=BF?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E8=A2=AB=E5=BC=B9=E6=A1=86=E5=BD=B1=E5=93=8D?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jest.config.js | 11 ++--------- testSequencer.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 testSequencer.js diff --git a/jest.config.js b/jest.config.js index b33c151f..fd80b0b9 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 00000000..ff7368f7 --- /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 -- GitLab