我使用Cypress作为 API 和 UI 测试的自动化框架。我已经编写了多个正在运行并通过的 API 测试,但它们只是验证返回response.status的200. 我想将来自 a 的响应 jsonGET与存储的“预期”响应进行比较,以确认 JSON 响应数据是正确的。
我在我的代码块中尝试了to.deep.equal和的不同变体。但我不想验证只有一个字段返回正确的值,我想验证一堆不同的字段是否返回正确的值。我的请求返回超过 100 行嵌套的 JSON 字段/值,而我只想验证彼此嵌套的 20 个左右的字段/值。deepEquals.then(response => {}GET
cy.request({
method: 'GET',
log: true,
url: 'https://dev.api.random.com/calculators/run-calculate/524/ABC',
headers: {
'content-type': 'application/json',
'x-api-key': calcXApiKey
},
body: {}
}).then(response => {
const respGet = response.body
const tPrice = response.body.data.calculations.t_costs[0].comparison.t_price
cy.log(respGet, tPrice)
assert.deepEqual({
tPrice
}, {
t_price: '359701'
})
// assert.equal(response.status, 200) -- This works great
})
Run Code Online (Sandbox Code Playgroud)
错误= …
我正在尝试使用Expo为我的React Native应用程序创建一个自动化的UI测试套件。我到处都在寻找好的教程,但是当我进入实际的测试写作部分时,由于诸如“意外的标识符/令牌”之类的环境问题import Icon from...或其他愚蠢的问题,我找不到任何解决方法的教程,因此我的测试甚至无法运行他们。我实际上花了一个星期的时间来解决这些问题。
我是React Native的新手,Jest / Detox / Expo的新手
这是我的package.json
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"test": "node_modules/.bin/jest test/**/*.spec.js",
"eject": "expo eject"
},
"jest": {
"verbose": true,
"preset": "jest-expo"
},
"dependencies": {
"apsl-react-native-button": "^3.1.1",
"react": "16.5.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
"react-native-camera": "git+https://git@github.com/react-native-community/react-native-camera.git",
"react-native-camera-roll-picker": "^1.2.3",
"react-native-elements": "^1.0.0",
"react-native-fontawesome": "^6.0.1",
"react-native-is-iphonex": "^1.0.1",
"react-native-vector-icons": "^6.2.0",
"react-navigation": "^3.1.5"
},
"devDependencies": {
"babel-preset-expo": "^5.0.0",
"bunyan-debug-stream": "^2.0.0",
"detox": "^10.0.9",
"detox-expo-helpers": "^0.6.0",
"expo-detox-hook": "^1.0.10",
"jest-expo": "^32.0.0", …Run Code Online (Sandbox Code Playgroud)