From 7c579c2ef17dd73a4d9b7240ab91da8e1dc0b4c4 Mon Sep 17 00:00:00 2001 From: fanniehuang Date: Wed, 31 Mar 2021 11:13:52 +0800 Subject: [PATCH] =?UTF-8?q?feat(e2e):=20=E4=BF=AE=E5=A4=8Dnomock=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E4=B8=8D=E7=94=9F=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit re #80 --- packages/wxa-cli/src/tester/wxa-e2eTest/e2eTestCaseTpl.ejs | 6 +++--- packages/wxa-cli/src/tester/wxa-e2eTest/runTestCase.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/wxa-cli/src/tester/wxa-e2eTest/e2eTestCaseTpl.ejs b/packages/wxa-cli/src/tester/wxa-e2eTest/e2eTestCaseTpl.ejs index ef424627..e0ad28e5 100644 --- a/packages/wxa-cli/src/tester/wxa-e2eTest/e2eTestCaseTpl.ejs +++ b/packages/wxa-cli/src/tester/wxa-e2eTest/e2eTestCaseTpl.ejs @@ -11,8 +11,8 @@ let testCaseNameArr = JSON.parse('<%- testCaseNameArr %>') let testDir = '<%= testDir %>'; let screenshotDirname = '<%- screenshotPath %>' let screenshotDiff = <%- screenshotDiff %>; +let mockApi = <%- mockApi %>; let base = <%- base %>; -let noMockApi = <%- noMockApi%> let customExpect = <%- customExpect%> const sleep = t => new Promise(resolve => setTimeout(resolve, t)); @@ -73,7 +73,7 @@ for (let j = 0; j < testCaseNameArr.length; j++) { let apiMockMap = require(path.join(testDir, testName, `./api.json`)); // for (let i = 0; i < mockWxMethodConfig.length; i++) { <% mockWxMethodConfig.forEach(function(mockItem){ %> - <% if(mockItem.name !== 'request' || !noMockApi) %> + <% if(mockItem.name !== 'request' || mockApi) {%> await miniProgram.mockWxMethod( '<%- mockItem.name %>', function(config, apiMockMap) { @@ -92,7 +92,7 @@ for (let j = 0; j < testCaseNameArr.length; j++) { }, apiMockMap ) - <% }); %> + <% }}); %> // 开始回放+截屏 page = await miniProgram.reLaunch(`/${record[0].action.page}`); diff --git a/packages/wxa-cli/src/tester/wxa-e2eTest/runTestCase.js b/packages/wxa-cli/src/tester/wxa-e2eTest/runTestCase.js index 3042d4aa..c0156791 100644 --- a/packages/wxa-cli/src/tester/wxa-e2eTest/runTestCase.js +++ b/packages/wxa-cli/src/tester/wxa-e2eTest/runTestCase.js @@ -71,7 +71,7 @@ export default async function(cmd, wxaConfigs) { screenshotPath: screenshotPath.replace(' ', '_').replace(/:/g, '.'), base: !!cmd.base, screenshotDiff: screenshotDiff, - noMockApi: !!cmd.noMock, + mockApi: cmd.mock, customExpect: !!cmd.customExpect, mockWxMethodConfig });