cma-template
Advanced tools
Comparing version 0.1.4 to 0.1.5
{ | ||
"name": "cma-template", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "> TODO: description", | ||
@@ -26,3 +26,3 @@ "author": "helinjiang <onehlj@qq.com>", | ||
}, | ||
"gitHead": "5958a3cd1e2acd728c5b7c137a3d4fcc72e58af7" | ||
"gitHead": "7844dcb795a3f60c999770a047551226542899af" | ||
} |
@@ -6,2 +6,31 @@ const _ = require('lodash'); | ||
/** | ||
* 设置浏览器打开时所模拟的设备参数 | ||
* | ||
* 内置的设备:https://github.com/puppeteer/puppeteer/blob/main/src/common/DeviceDescriptors.ts | ||
* 更多实践请查阅:https://github.com/matmanjs/test-automation-training/tree/master/matman/04.device-emulation | ||
*/ | ||
const DEVICE = { | ||
// 内置的设备(iOS):iPhone 6 | ||
IOS_IPHONE_6: 'iPhone 6', | ||
// 内置的设备(安卓):Galaxy Note 3 | ||
ANDROID_GALAXY_NOTE_3: 'Galaxy Note 3', | ||
// 自定义设备 | ||
CUSTOM_DEVICE: { | ||
name: 'My iPhone 6', | ||
userAgent: | ||
'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1', | ||
viewport: { | ||
width: 375, | ||
height: 667, | ||
deviceScaleFactor: 2, | ||
isMobile: true, | ||
hasTouch: true, | ||
isLandscape: false, | ||
}, | ||
}, | ||
}; | ||
/** | ||
* 创建端对端测试的 page driver | ||
@@ -16,3 +45,3 @@ * | ||
pageDriverOpts, | ||
queryDataMap | ||
queryDataMap, | ||
) { | ||
@@ -22,3 +51,3 @@ // 创建 PageDriver,API 详见 https://matmanjs.github.io/matman/api/ | ||
new BrowserRunner(), | ||
_.merge({}, pageDriverOpts, { caseModuleFilePath }) | ||
_.merge({}, pageDriverOpts, { caseModuleFilePath }), | ||
); | ||
@@ -32,3 +61,3 @@ | ||
await pageDriver.useMockstar( | ||
_.merge({}, queryDataMap, pageDriverOpts.queryDataMap) | ||
_.merge({}, queryDataMap, pageDriverOpts.queryDataMap), | ||
); | ||
@@ -38,3 +67,3 @@ } | ||
// 设置浏览器设备型号 | ||
await pageDriver.setDeviceConfig('iPhone 6'); | ||
await pageDriver.setDeviceConfig(DEVICE.IOS_IPHONE_6); | ||
@@ -50,2 +79,3 @@ // 设置截屏 | ||
createPageDriver, | ||
DEVICE, | ||
}; |
{ | ||
"name": "whistle", | ||
"scripts": { | ||
"use-dev": "w2 add rules/whistle.dev.js --force", | ||
"use-prod": "w2 add rules/whistle.prod.js --force" | ||
} | ||
"name": "whistle", | ||
"scripts": { | ||
"use-dev": "w2 add rules/whistle.dev.js --force", | ||
"use-prod": "w2 add rules/whistle.prod.js --force" | ||
} | ||
} |
67681
1142