Created
April 19, 2020 18:35
-
-
Save qunabu/4d151c9c0ace24290bb4942897e95397 to your computer and use it in GitHub Desktop.
Strapi simple unit test
This file contains 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
const request = require("supertest"); | |
// function from gist file | |
const { setupStrapi } = require("./helpers/strapi"); | |
// We're setting timeout because sometimes bootstrap can take 5-7 seconds (big apps) | |
jest.setTimeout(10000); | |
let app; // this is instance of the the strapi | |
beforeAll(async () => { | |
app = await setupStrapi(); // return singleton so it can be called many times | |
}); | |
it("should respond with 200 on /heartbeat", async (done) => { | |
request(app.server) // app server is and instance of Class: http.Server | |
.get("/heartbeat") | |
.expect(200) // expecting response header code to by 200 success | |
.expect("Hello World!") // expecting reponse text to be "Hello World!" | |
.end(done); // let jest know that test is finished | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment