Skip to content

Commit

Permalink
➕ add describe.skip
Browse files Browse the repository at this point in the history
  • Loading branch information
59naga committed Aug 20, 2018
1 parent 0c40e77 commit 8b9ebcd
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ spec("foo", () => {});
1 passing (7 ms)
```

## `spec(title)`, `spec.skip`
## `spec(title)`, `spec.skip(title)`

```js
spec("foo");
Expand Down Expand Up @@ -209,6 +209,7 @@ spec.setOptions({ concurrency: 1, timeout: 100 });
BDD Interface
---
## `describe(title, fn)`
## `describe(title)`, `describe.skip(title)`

```js
import { describe } from "eastern";
Expand Down
12 changes: 11 additions & 1 deletion src/describe.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class Describe {
},
options
);

this.isOnly = false;
this.hooks = {
before: [],
Expand All @@ -31,6 +31,7 @@ export default class Describe {

this.block = this.it.bind(this);
this.block.describe = this.describe.bind(this);
this.block.describe.skip = this.describeSkip.bind(this);
this.block.it = this.block;
this.block.skip = this.itSkip.bind(this);
this.block.only = this.itOnly.bind(this);
Expand Down Expand Up @@ -98,6 +99,15 @@ export default class Describe {
return describe.finish;
});
}
describeSkip(title) {
this.describes.push(() => {
const reporter = this.opts.reporter;

reporter.describe(title);

return Promise.resolve();
});
}
child(title, options) {
const opts = Object.assign({}, options);
opts.reporter = this.opts.reporter.child();
Expand Down
10 changes: 10 additions & 0 deletions test/describe/skip/expected.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const code = 1;
export const stdout = `
foo
bar
baz
0 passing (ELAPSED ms)
`;

export const stderr = ``;
26 changes: 26 additions & 0 deletions test/describe/skip/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { describe } from "eastern";
import delay from "delay";

describe("foo");
describe.skip("bar", it => {
it("bar-foo");
it.skip("bar-foo");
it("bar-baz", async () => {
await delay(15);
});

it("bar-bar", () => {});
it("bar-bar", () => {});
it("bar-bar", () => {});
});
describe.skip("baz", it => {
it("baz-foo");
it.skip("baz-foo");
it("baz-baz", async () => {
await delay(5);
});

it("baz-bar", () => {});
it("baz-bar", () => {});
it("baz-bar", () => {});
});

0 comments on commit 8b9ebcd

Please sign in to comment.