Is there a way to make tests depend on each other?
partounian opened this issue · 0 comments
partounian commented
For example instead of
describe("Promises", function () {
it("should support asserting Biggie's best track", function () {
var artist = "Notorious B.I.G.";
return chakram.get("https://api.spotify.com/v1/search?q="+artist+"&type=artist")
.then(function (searchResponse) {
var bigID = searchResponse.body.artists.items[0].id;
return chakram.get("https://api.spotify.com/v1/artists/"+bigID+"/top-tracks?country=GB");
})
.then(function (topTrackResponse) {
var topTrack = topTrackResponse.body.tracks[0];
expect(topTrack.name).to.contain("Old Thing Back");
});
});
});
or
describe("BDD + Hooks", function () {
var thingName;
before("post dweet", function () {
thingName = "chakramtest" + Math.floor(Math.random()*2000);
return chakram.post("https://dweet.io/dweet/for/"+thingName, {
testing: "your API"
});
});
it("should support getting latest dweet", function () {
var postedData = chakram.get("https://dweet.io/get/latest/dweet/for/"+thingName);
return expect(postedData).to.have.json('with[0].content', {
testing: "your API"
});
});
after("update dweet with result", function () {
return chakram.post("https://dweet.io/dweet/for/"+thingName, {
testing: "passed"
});
});
});
have them as separate tests that are dependent on each other? before and after are nice but what if it is more than three steps? In my specific case I want to create, update and then delete a gist, but would like them to be separate tests.