sd-bee
v0.0.37
Published
a test runner based on cypress
Downloads
7
Readme
sd-bee
a test runner based on cypress
Installation
npm install sd-bee
Command 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_folder
Module 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
:
enableHeaded
enable headed browser mode,false
defaultenableVideos
enable generate videos for whole test task,false
defaultdisableOverwriteReport
disable overwrite the report file,true
defaultfixturesFolder
specify the absolute path of the fixture foldercustomCommandsFilePath
specify the absolute path of the custom commands fileuserAgent
specify 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.html
The 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.mp4
Test 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.