Commit 0e9c1e6e authored by xie.qin's avatar xie.qin

To support download openapi file.

parent 89eef867
......@@ -23,7 +23,8 @@ Cypress几年前还属于一个比较小众的Web测试方案,现如今已有
## 测试执行及结果展示:
- 安装Node.js 12 or 14 and above
- 安装依赖
- node install
- node install
- 如果需要在Linux服务器上运行,[点击链接](https://docs.cypress.io/guides/continuous-integration/introduction#Dependencies)安装其它依赖
- 调试窗口:
- npm run cypress:open
- 运行命令:
......
......@@ -21,7 +21,7 @@
"openMode": 0
},
"pageLoadTimeout": 10000,
"defaultCommandTimeout": 5000,
"defaultCommandTimeout": 10000,
"testFiles": "**/*.feature",
"chromeWebSecurity": false
}
......@@ -35,11 +35,13 @@ Then('download openapi file and save', () => {
cy.log('**read downloaded file**')
// file path is relative to the working folder
const filename = path.join(downloadsFolder, '2.X版本_OpenAPI.json')
//debugger
cy.task('getFileSize', filename).then((fileSize) => {
debugger
// file path is relative to the working folder
const filename = path.join(downloadsFolder, '/2.X版本_OpenAPI.json')
cy.log(filename)
cy.readFile(filename)
/**
* cy.task('getFileSize', filename).then((fileSize) => {
expect(fileSize).to.greaterThan(1500000)
})
*/
})
\ No newline at end of file
......@@ -18,6 +18,7 @@
// eslint-disable-next-line no-unused-vars
const cucumber = require('cypress-cucumber-preprocessor').default
const { rmdir, statSync, mkdirSync, writeFile } = require('fs')
const path = require('path')
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
......@@ -38,16 +39,17 @@ module.exports = (on, config) => {
})
})
},
getFileSize (filePath) {
console.log('getting size of file: %s', filePath)
return new Promise((resolve, reject) => {
var fileSize = statSync(filePath, (err,stats) => {
getFileSize (fileName) {
console.log('getting size of file: %s', fileName)
// wait file finished to download
return new Promise((resolve, reject) => {
statSync(fileName, (err, stats) => {
if (err) {
console.error(err)
return reject(err)
}
resolve(stats.size)
});
})
})
},
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment