Skip to content

Commit

Permalink
🐎 changed to run as parallel as possible
Browse files Browse the repository at this point in the history
Can manually run as serial using `.setOptions`
  • Loading branch information
59naga committed Aug 20, 2018
1 parent b0c9cc8 commit a80e4a1
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 6 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ beep
## `spec.beforeEach`

```js
spec.setOptions({ concurrency: 1 });
spec.beforeEach(async () => {
await delay(5);
console.log("foo");
Expand All @@ -180,6 +181,7 @@ foo
```js
import delay from "delay";

spec.setOptions({ concurrency: 1 });
spec.afterEach(async () => {
await delay(5);
console.log("bar");
Expand All @@ -200,15 +202,18 @@ bar
3 passing (28 ms)
```

## `spec.setOptions`
## `spec.setOptions` / `it.setOptions`

```js
spec.setOptions({ concurrency: 1, timeout: 100 });
```

> Specs of the same level are executed in parallel, and there is a possibility that hooks conflict.
> In that case, please set the `concurrency` of that level to 1 and execute it in series. using `spec.setOptions`
BDD Interface
---
## `describe(title, fn)`
## `describe(title, fn(spec){})`
## `describe(title)`, `describe.skip(title)`

```js
Expand Down
4 changes: 0 additions & 4 deletions src/describe.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,10 @@ export default class Describe {
}

beforeEach() {
this.setOptions({ concurrency: 1 });

const args = [...arguments];
this.hooks.beforeEach.push(() => execute(...args));
}
afterEach() {
this.setOptions({ concurrency: 1 });

const args = [...arguments];
this.hooks.afterEach.push(() => execute(...args));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import spec from "eastern";
import delay from "delay";

spec.setOptions({ concurrency: 1 });
spec.afterEach(async () => {
await delay(5);
console.log("bar");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import spec from "eastern";
import delay from "delay";

spec.setOptions({ concurrency: 1 });
spec.beforeEach(async () => {
await delay(5);
console.log("foo");
Expand Down
2 changes: 2 additions & 0 deletions test/describe/mixin-throw/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe("1", ({ before, beforeEach, afterEach, after, it, describe }) => {
console.log(" 1-after");
});

it.setOptions({ concurrency: 1 });
it("1-1");
it.skip("1-2");
it("1-notonly-1", () => {});
Expand Down Expand Up @@ -42,6 +43,7 @@ describe("1", ({ before, beforeEach, afterEach, after, it, describe }) => {
console.log(" 3-after");
});

it.setOptions({ concurrency: 1 });
it("3-1");
it.skip("3-2");
it("3-notonly-1", () => {});
Expand Down
2 changes: 2 additions & 0 deletions test/describe/mixin/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe("1", ({ before, beforeEach, afterEach, after, it, describe }) => {
console.log(" 1-after");
});

it.setOptions({ concurrency: 1 });
it("1-1");
it.skip("1-2");
it("1-notonly-1", () => {});
Expand All @@ -40,6 +41,7 @@ describe("1", ({ before, beforeEach, afterEach, after, it, describe }) => {
console.log(" 3-after");
});

it.setOptions({ concurrency: 1 });
it("3-1");
it.skip("3-2");
it("3-notonly-1", () => {});
Expand Down

0 comments on commit a80e4a1

Please sign in to comment.