Skip to content

Instantly share code, notes, and snippets.

View qunabu's full-sized avatar

Mateusz Wojczal qunabu

View GitHub Profile
@qunabu
qunabu / t.js
Created November 26, 2020 10:24
describe("MyGallery", () => {
it("init set correct property when called (thumb size, thumbs count)", () => {});
});
@qunabu
qunabu / TestRules.js
Created November 26, 2020 10:23
TestRules.js
describe("A set of functionalities", () => {
it("should do something nice", () => {});
describe("A subset of functionalities", () => {
it("should do something great", () => {});
it("should do something awesome", () => {});
});
describe("Another subset of functionalities", () => {
it("should also do something great", () => {});
@qunabu
qunabu / TestRules.js
Created November 26, 2020 10:22
TestRules.js
describe("A set of functionalities", () => {
it("a set of functionalities should do something nice", () => {});
it("a subset of functionalities should do something great", () => {});
it("a subset of functionalities should do something awesome", () => {});
it("another subset of functionalities should also do something great", () => {});
});
@qunabu
qunabu / factories.js
Created November 26, 2020 09:35
Faktorie
const faker = require("faker");
const userFactory (data = {}) => {
const username = faker.hacker.noun() + faker.random.number();
return {
username: username,
email: `${username}@crowdhome.test`,
phoneNumber: faker.phone.phoneNumber(),
...data
}
}
@qunabu
qunabu / mock-api.js
Created November 26, 2020 09:35
Mockowanie API
const request = require("supertest");
jest.mock("node-fetch", () => require("fetch-mock-jest").sandbox());
const fetchMock = require("node-fetch");
it("validates general PDF investment for user", async (done) => {
fetchMock.mock("https://weryfikacjapodpisu.pl/api/verify", {
body: fs.readFileSync("./tests/poa/weryf_correct.json", "utf8"),
});
await request(app.server)
@qunabu
qunabu / test-mocks.js
Created November 26, 2020 09:34
Test Mocki
const should = require('should');
const mockery = require('mockery');
const nodemailerMock = require('nodemailer-mock');
describe('Tests that send email', async () {
before(async () {
mockery.enable({warnOnUnregistered: false}); // Enable mockery to mock objects
mockery.registerMock('nodemailer', nodemailerMock)
});
@qunabu
qunabu / test-mocks
Created November 26, 2020 09:33
Test Mocki
const should = require('should');
const mockery = require('mockery');
const nodemailerMock = require('nodemailer-mock');
describe('Tests that send email', async () {
before(async () {
mockery.enable({warnOnUnregistered: false}); // Enable mockery to mock objects
mockery.registerMock('nodemailer', nodemailerMock)
});
@qunabu
qunabu / test-prepare.js
Created November 26, 2020 09:32
Przygotowanie do testów
beforeEach(() => {
initializeCityDatabase();
});
afterEach(() => {
clearCityDatabase();
});
test("city database has Vienna", () => {
expect(isCity("Vienna")).toBeTruthy();
@qunabu
qunabu / test-runners.js
Created November 26, 2020 09:27
Test runners
// Jest
describe("Sum numbers", () => {
test("it should sum two numbers correctly", () => {
expect(1 + 2).toEqual(3);
});
});
// Jasmine
describe("Sum numbers", function () {
it("should sum two numbers correctly", function () {
@qunabu
qunabu / test-acceptance.js
Created November 26, 2020 09:24
Test Akceptacyjny
// TEST. framework codeceptjs
Feature("My First Test");
Scenario("test something", ({ I }) => {
I.amOnPage("https://github.com");
I.see("GitHub");
});