sd-bee v0.0.37
sd-bee
a test runner based on cypress
Installation
npm install sd-beeCommand Line
The command line will automatically open the browser, show the process of running the test case, and display the test results in the browser.
# run a test file
npx bee run /tmp/my_test_folder/something.spec.js
# or run a specified test folder
npx bee run /tmp/my_test_folderModule Api
The module interface provides three functions:
- run
- report
- getHTMLResultPathById
The run function receives an object mapped with the test file name and the contents of the test file, runs all of the test contents in a headless browser, and returns an object mapped with the test file name and test result.
const bee = require('sd-bee')
const filesMapContent = {
'/tmp/my_test_folder/a.spec.js': 'context(\'a\', () => {it(\'case 1\', ()=>{})})\n',
'/tmp/my_test_folder/b.spec.js': 'context(\'b\', () => {it(\'case 1\', ()=>{})})\n',
'/tmp/my_test_folder/c.spec.js': 'context(\'c\', () => {it(\'case 1\', ()=>{})})\n'
}
bee.run(filesMapContent, options).then(filesMapResult => {
Object.keys(filesMapResult).forEach(fileName => {
console.log(fileName)
console.log(filesMapResult[fileName])
})
}).catch(console.log)Available options:
enableHeadedenable headed browser mode,falsedefaultenableVideosenable generate videos for whole test task,falsedefaultdisableOverwriteReportdisable overwrite the report file,truedefaultfixturesFolderspecify the absolute path of the fixture foldercustomCommandsFilePathspecify the absolute path of the custom commands fileuserAgentspecify the userAgent for current test task (once)
The report function receives an object mapped with the test file name and the test result, writes the test results to disk, merges them into a single result, generates a report in HTML format, and finally returns the id of the test object.
const filesMapResult = {
'/tmp/my_test_folder/a.spec.js': '...',
'/tmp/my_test_folder/b.spec.js': '...',
'/tmp/my_test_folder/c.spec.js': '...'
}
let id = bee.report(filesMapResult)
console.log(id)The getHTMLResultPathById function receives the id of a test object and returns the absolute path of the HTML report file for this test object.
const bee = require('sd-bee')
console.log(
bee.getHTMLResultPathById('d168b0198a9ead9f0171358d09a828e7')
)
// /tmp/sd-bee/d168b0198a9ead9f0171358d09a828e7/html_results/d168b0198a9ead9f0171358d09a828e7.htmlThe getVideoResultPathById function receives the id of a test object and returns the absolute path of the Video report file for this test object.
const bee = require('sd-bee')
console.log(
bee.getVideoResultPathById('d168b0198a9ead9f0171358d09a828e7')
)
// /tmp/sd-bee/d168b0198a9ead9f0171358d09a828e7/videos/0.spec.js.mp4Test object id generation logic:
Sd-bee will map the object according to the file name passed in, extract the file name, and use the md5 algorithm to generate the id of the test object.
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago