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
// TEST. framework cypress | |
describe("My First Test", () => { | |
it("Gets, types and asserts", () => { | |
cy.visit("https://example.cypress.io"); | |
cy.contains("type").click(); | |
// Should be on a new URL which includes '/commands/actions' | |
cy.url().should("include", "/commands/actions"); | |
// Get an input, type into it and verify that the value has been updated | |
cy.get(".action-email") | |
.type("[email protected]") |
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
// app | |
const request = require("supertest"); | |
const app = require("express")(); | |
app.get("/user", (req, res) => res.status(200).json({ name: "john" })); | |
// TEST. framework jest | |
request(app) | |
.get("/user") | |
.expect("Content-Type", /json/) |
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
// app | |
const add = (a, b) => a + b; | |
// TEST. framework jest | |
expect(add(2, 2)).toBe(4); |
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
const request = require("supertest"); | |
const userFactory = require("./../user/factory"); | |
const nodemailerMock = require("nodemailer-mock"); | |
// const { jwt, grantPrivilage } = require("./../helpers/strapi"); | |
describe("Reset password", () => { | |
let user; | |
beforeAll(async (done) => { | |
user = await userFactory.createUser(strapi); |
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
const request = require("supertest"); | |
const { updatePluginStore, responseHasError } = require("./../helpers/strapi"); | |
const { createUser, defaultData, mockUserData } = require("./factory"); | |
const nodemailerMock = require("nodemailer-mock"); | |
describe("Default User methods", () => { | |
let user; | |
beforeAll(async (done) => { | |
user = await createUser(strapi); |
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
const request = require("supertest"); | |
const userFactory = require("./../user/factory"); | |
const { jwt, grantPrivilage } = require("./../helpers/strapi"); | |
describe("Hello methods", () => { | |
let user; | |
beforeAll(async (done) => { | |
user = await userFactory.createUser(strapi); | |
await grantPrivilage(1, "permissions.application.controllers.hello.hi"); // 1 is default role for new confirmed users | |
done(); |
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
module.exports = ({ env }) => ({ | |
email: { | |
provider: "mocknodemailer", | |
providerOptions: {}, | |
settings: {}, | |
}, | |
}); |
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
beforeAll(async (done) => { | |
user = await userFactory.createUser(strapi); | |
await grantPrivilage(1, "permissions.application.controllers.hello.hi"); | |
done(); | |
}); |
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
it("should return `Hi ${user.username}`", async (done) => { | |
const token = await jwt(user.id); | |
await request(strapi.server) // app server is and instance of Class: http.Server | |
.get("/hi") | |
.set("Authorization", "Bearer " + token) | |
.expect(200) // Expect response http code 200 | |
.then((data) => { | |
expect(data.text).toBe(`Hi ${user.username}`); // expect the response welcome text | |
}); | |
done(); |
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
module.exports = { | |
hi: (ctx) => { | |
ctx.send(`Hi ${ctx.state.user.username}`); | |
}, | |
}; |