Answers for "jest"

5

how to install jest

npm install --save-dev jest

// Yarn
yarn add --dev jest
Posted by: Guest on June-10-2020
1

jest

const sum = require('./sum');

test('adds 1 + 2 to equal 3', () => {
  expect(sum(1, 2)).toBe(3);
});
Copy
Posted by: Guest on May-01-2020
0

jest

beforeAll(() => console.log('1 - beforeAll'));
afterAll(() => console.log('1 - afterAll'));
beforeEach(() => console.log('1 - beforeEach'));
afterEach(() => console.log('1 - afterEach'));
test('', () => console.log('1 - test'));
describe('Scoped / Nested block', () => {
  beforeAll(() => console.log('2 - beforeAll'));
  afterAll(() => console.log('2 - afterAll'));
  beforeEach(() => console.log('2 - beforeEach'));
  afterEach(() => console.log('2 - afterEach'));
  test('', () => console.log('2 - test'));
});

// 1 - beforeAll
// 1 - beforeEach
// 1 - test
// 1 - afterEach
// 2 - beforeAll
// 1 - beforeEach
// 2 - beforeEach
// 2 - test
// 2 - afterEach
// 1 - afterEach
// 2 - afterAll
// 1 - afterAll
Copy
Posted by: Guest on July-17-2020
0

jest

function sum(a, b) {
  return a + b;
}
module.exports = sum;
Copied
Posted by: Guest on May-01-2020
0

jest

Jest is a JavaScript testing framework maintained by Facebook, Inc. with a
focus on simplicity.

It works with projects using: Babel, TypeScript, Node.js, React, Angular and
Vue.js.

It aims to work out of the box and config free.
Posted by: Guest on June-19-2020
0

jest

yarn add --dev jest
Posted by: Guest on December-18-2020

Browse Popular Code Answers by Language