Skip to content

Commit

Permalink
feat: change default module,group,unit describe
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden committed Jun 6, 2021
1 parent ec8989e commit 9592bb4
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 110 deletions.
8 changes: 4 additions & 4 deletions src/Cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class Cases {
this.clients = clients;
this.mixin = mixin;
for (const [moduleName, props] of modules) {
this.describes[moduleName] = "module " + moduleName;
this.describes[moduleName] = moduleName;
for (const prop of props) {
this.addProp([moduleName], prop);
}
Expand Down Expand Up @@ -78,7 +78,7 @@ export default class Cases {

const valueObject = value as JsonaObject;
let describe = this.retriveAnnoDescribe(paths, value);
if (!describe) describe = "group " + _.last(paths);
if (!describe) describe = _.last(paths);
this.describes[paths.join(".")] = describe;

const client = this.retriveAnnoClient(paths, value);
Expand All @@ -95,7 +95,7 @@ export default class Cases {
this.caseIds.push(group.paths.join("."));

const cases = parent ? parent.cases : this.cases;
const prevCase = cases[cases.length - 1];
const prevCase = _.last(cases);
if (prevCase) group.prev = prevCase.id;
cases.push(group);

Expand All @@ -115,7 +115,7 @@ export default class Cases {
const valueObject = value as JsonaObject;

let describe = this.retriveAnnoDescribe(paths, value);
if (!describe) describe = "unit " + _.last(paths);
if (!describe) describe = _.last(paths);
this.describes[paths.join(".")] = describe;

let client = this.retriveAnnoClient(paths, value);
Expand Down
2 changes: 1 addition & 1 deletion src/Reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class Reporter {
}
public async endCase(args: EndCaseArgs) {
let timeStr = "";
if (args.timeMs) {
if (args.timeMs > 10) {
timeStr = " (" + (args.timeMs / 1000).toFixed(3) + ")";
}
const dump = _.get(args.state, "run.dump");
Expand Down
44 changes: 22 additions & 22 deletions tests/__snapshots__/cases.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports[`cases invalid prop key 1`] = `
`;

exports[`cases invalid run options 1`] = `
"module main
"main
fail# invalid unit.skip
main.test1.run.skip: should be boolean value
fail# invalid unit.delay
Expand Down Expand Up @@ -58,7 +58,7 @@ exports[`cases invalid unit value type 1`] = `
`;

exports[`cases merge mixin 1`] = `
"module main
"main
single mixin ✔
multiple mixin ✔
omit mixin if exist prop ✔
Expand All @@ -67,8 +67,8 @@ exports[`cases merge mixin 1`] = `
`;

exports[`cases run --reset 1`] = `
"module main
unit vars ✔
"main
vars ✔
dump ✔
{
\\"req\\": {
Expand All @@ -93,39 +93,39 @@ exports[`cases run --reset 1`] = `
`;

exports[`cases run 1`] = `
"module main
unit vars ✔
"main
vars ✔
skip ⌾
delay
unit test2 ✔
test2 ✔
fail# retry
unit test1 ✔
unit test3 ✘
unit test1 ✔
unit test3 ✘
unit test1 ✔
unit test3 ✘
test1 ✔
test3 ✘
test1 ✔
test3 ✘
test1 ✔
test3 ✘
loop
unit test1 ✔
unit test4 ✔
unit test1 ✔
unit test4 ✔
test1 ✔
test4 ✔
test1 ✔
test4 ✔
1. unit test3(main.group3.test3)
1. test3(main.group3.test3)
main.group3.test3.res.v1: b ≠ a
2. unit test3(main.group3.test3)
2. test3(main.group3.test3)
main.group3.test3.res.v1: b ≠ a
3. unit test3(main.group3.test3)
3. test3(main.group3.test3)
main.group3.test3.res.v1: b ≠ a
"
`;

exports[`cases run group 1`] = `
"module main
unit vars ✔
"main
vars ✔
dump ✔
{
\\"req\\": {
Expand Down
120 changes: 60 additions & 60 deletions tests/__snapshots__/cli.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`cli restart failed run group 1`] = `
"module main
"main
fail# retry
unit test1 ✔
unit test3 ✘
test1 ✔
test3 ✘
main.group3.test3.res.v1: b ≠ a
{
Expand All @@ -15,8 +15,8 @@ exports[`cli restart failed run group 1`] = `
\\"v1\\": \\"a\\"
}
}
unit test1 ✔
unit test3 ✘
test1 ✔
test3 ✘
main.group3.test3.res.v1: b ≠ a
{
Expand All @@ -27,8 +27,8 @@ exports[`cli restart failed run group 1`] = `
\\"v1\\": \\"a\\"
}
}
unit test1 ✔
unit test3 ✘
test1 ✔
test3 ✘
main.group3.test3.res.v1: b ≠ a
{
Expand All @@ -43,14 +43,14 @@ exports[`cli restart failed run group 1`] = `
`;

exports[`cli run group 1`] = `
"module main
unit vars ✔
"main
vars ✔
skip ⌾
delay
unit test2 ✔
test2 ✔
fail# retry
unit test1 ✔
unit test3 ✘
test1 ✔
test3 ✘
main.group3.test3.res.v1: b ≠ a
{
Expand All @@ -61,8 +61,8 @@ exports[`cli run group 1`] = `
\\"v1\\": \\"a\\"
}
}
unit test1 ✔
unit test3 ✘
test1 ✔
test3 ✘
main.group3.test3.res.v1: b ≠ a
{
Expand All @@ -73,8 +73,8 @@ exports[`cli run group 1`] = `
\\"v1\\": \\"a\\"
}
}
unit test1 ✔
unit test3 ✘
test1 ✔
test3 ✘
main.group3.test3.res.v1: b ≠ a
{
Expand All @@ -89,9 +89,9 @@ exports[`cli run group 1`] = `
`;

exports[`cli start from first 1`] = `
"module main
unit test1 ✔
unit test2 ✘
"main
test1 ✔
test2 ✘
main.test2.res.v1: b ≠ a
{
Expand All @@ -106,8 +106,8 @@ exports[`cli start from first 1`] = `
`;

exports[`cli start from last failed 1`] = `
"module main
unit test2 ✘
"main
test2 ✘
main.test2.res.v1: b ≠ a
{
Expand All @@ -122,8 +122,8 @@ exports[`cli start from last failed 1`] = `
`;

exports[`cli still start from last failed 1`] = `
"module main
unit test2 ✘
"main
test2 ✘
main.test2.res.v1: b ≠ a
{
Expand All @@ -138,9 +138,9 @@ exports[`cli still start from last failed 1`] = `
`;

exports[`cli target folder 1`] = `
"module main
unit test1 ✔
unit test2 ✘
"main
test1 ✔
test2 ✘
main.test2.res.v1: b ≠ a
{
Expand All @@ -155,10 +155,10 @@ exports[`cli target folder 1`] = `
`;

exports[`cli target folder with options --env 1`] = `
"module main
unit test1 ✔
module mod1
unit test1 ✘
"main
test1 ✔
mod1
test1 ✘
mod1.test1.res.v1: b ≠ a
{
Expand All @@ -173,44 +173,44 @@ module mod1
`;

exports[`cli with options --ci 1`] = `
"module main
unit test1 ✔
unit test2 ✘
unit test3 ✘
unit test4 ✔
module mod1
unit test1 ✘
unit test2 ✔
"main
test1 ✔
test2 ✘
test3 ✘
test4 ✔
mod1
test1 ✘
test2 ✔
1. unit test2(main.test2)
1. test2(main.test2)
main.test2.res.v1: b ≠ a
2. unit test3(main.test3)
2. test3(main.test3)
main.test3.res.v1: b ≠ a
3. unit test1(mod1.test1)
3. test1(mod1.test1)
mod1.test1.res.v1: b ≠ a
"
`;

exports[`cli with options --dry-run 1`] = `
"module main
unit test1 (main.test1)
unit test2 (main.test2)
unit test3 (main.test3)
unit test4 (main.test4)
module mod1
unit test1 (mod1.test1)
unit test2 (mod1.test2)
"main
test1 (main.test1)
test2 (main.test2)
test3 (main.test3)
test4 (main.test4)
mod1
test1 (mod1.test1)
test2 (mod1.test2)
"
`;

exports[`cli with options --env 1`] = `
"module main
unit test1 ✔
module mod1
unit test1 ✘
"main
test1 ✔
mod1
test1 ✘
mod1.test1.res.v1: b ≠ a
{
Expand All @@ -225,14 +225,14 @@ module mod1
`;

exports[`cli with options --only 1`] = `
"module main
unit test4 ✔
"main
test4 ✔
"
`;

exports[`cli with options --only 2 1`] = `
"module mod1
unit test1 ✘
"mod1
test1 ✘
mod1.test1.res.v1: b ≠ a
{
Expand All @@ -247,9 +247,9 @@ exports[`cli with options --only 2 1`] = `
`;

exports[`cli with options --reset 1`] = `
"module main
unit test1 ✔
unit test2 ✘
"main
test1 ✔
test2 ✘
main.test2.res.v1: b ≠ a
{
Expand Down

0 comments on commit 9592bb4

Please sign in to comment.