Skip to content

setup tests with jest #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions __tests__/array.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// @ts-nocheck
const arrayEvery = Array.prototype.every;
const arrayFilter = Array.prototype.filter;
beforeAll(() => {
Array.prototype.every = undefined;
Array.prototype.filter = undefined;
});
afterAll(() => {
Array.prototype.every = arrayEvery;
Array.prototype.filter = arrayFilter;
});
describe("array tests", () => {
test("filter should work", () => {
require("../Array/filter");
const arr = [1, 2, 3];
const res = arr.filter((ele, i, arr) => ele === 1);
expect(res[0]).toBe(1);
});
test("every shoud work", () => {
require("../Array/every");
const arr = [1, 2, 3];
expect(
arr.every(function(ele, i, arr) {
return ele < 4;
})
).toBe(true);
});
});
18 changes: 18 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
testEnvironment: "jest-environment-node",
collectCoverage: true,
coverageReporters: ["lcov", "text"],
collectCoverageFrom: [
"Array/**/*.{js}",
"Date/**/*.{js}",
"Object/**/*.{js}"
],
coverageThreshold: {
global: {
branches: 75,
functions: 75,
lines: 75,
statements: 75
}
}
};
Loading