Last active
July 22, 2020 14:51
-
-
Save taras/392b9f89a88c0f428af531a91b95f5e6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let app = createAppInteractor(); | |
let signin = createAppInteractor(); | |
describe("sign-in", () => { | |
describe("when user is anonymous", () => { | |
beforeEach(async () => { | |
await app.visit('/sign-in'); | |
}); | |
it("shows sign-in page", () => { | |
expect(signin.isVisible).toBe(true); | |
}); | |
it("shows username", () => { | |
expect(signin.username.isVisible).toBe(true); | |
}); | |
it("show password", () => { | |
expect(signin.password.isVisible).toBe(true); | |
}); | |
}); | |
describe("when user is authenticated", () => { | |
beforEach(async () => { | |
await app.authenticate(); | |
}); | |
beforeEach(async () => { | |
await app.visit('/sign-in'); | |
}); | |
it('navigates user to home page', () => { | |
expect(app.currentUser).toBe("/"); | |
}); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ bigtest analyze mocha-example-test.js --type=mocha | |
BigTest analysis found the following tests in `mocha-example-test.js` | |
sign-in > when user is anonymous > shows sign-in page | |
line 6: async () => { | |
await app.visit('/sign-in'); | |
} | |
line 10: () => { | |
expect(signin.isVisible).toBe(true); | |
} | |
sign-in > when user is anonymous > shows username | |
line 6: async () => { | |
await app.visit('/sign-in'); | |
} | |
line 14: () => { | |
expect(signin.username.isVisible).toBe(true); | |
} | |
sign-in > when user is anonymous > show password | |
line 6: async () => { | |
await app.visit('/sign-in'); | |
} | |
line 18: () => { | |
expect(signin.password.isVisible).toBe(true); | |
} | |
sign-in > when user is authenticated > navigates user to home page | |
line 24: async () => { | |
await app.authenticate(); | |
} | |
line 28: async () => { | |
await app.visit('/sign-in'); | |
} | |
line 32: () => { | |
expect(app.currentUser).toBe("/"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let app = createAppInteractor(); | |
let signin = createAppInteractor(); | |
// This is a optimized version of the test suite above | |
// We're not going to make these optimizations yet, but | |
// eventually suggest that we can optimize the test suite this way. | |
export default test("sign-in") | |
.child("when user is anonymous", | |
test => test | |
.step("user is authenticated", async () => { | |
await app.visit('/sign-in'); | |
}) | |
.assertion("shows sign-in page", () => { | |
expect(signin.username.isVisible).toBe(true); | |
}) | |
.assertion("shows username", () => { | |
expect(signin.username.isVisible).toBe(true); | |
}) | |
.assertion("show password", () => { | |
expect(signin.password.isVisible).toBe(true); | |
})) | |
.child("when user is authenticated", test => test | |
.step(async () => { | |
await app.authenticate(); | |
}) | |
.step(async () => { | |
await app.visit('/sign-in'); | |
}) | |
.assertion("navigates user to home page", () => { | |
expect(app.currentUser).toBe("/"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I order to educate and explain the difference, it would be helpful to also provide a countervailing analysis of the bigtest suite. For example, in this example you go from four test cases to having just two (one for each child).
We could include a summary in the in
Or something like that.