Коммит 756d2169 создал по автору Martin Hanzel's avatar Martin Hanzel
Просмотр файлов

Move manual mocks to non-underscored folder

владелец 0e62cae7
Hello! This is where you place module mocks for Jest tests, so we can keep them all in one place.
- Place mocks for NPM packages, like `jquery`, into `node/`.
- Place mocks for GitLab classes and scripts into `gitlab/`.
Make sure to register the mock in `test_setup.js` if you add a new one. Jest will then automatically load the mock whenever you import the mocked package.
Mocks must export the same fields as the mocked module. So, if you're mocking a CommonJS package, use `module.exports` instead of the ES6 `export`.
\ Нет новой строки в конце файла
......@@ -8,8 +8,9 @@ process.on('unhandledRejection', global.promiseRejectionHandler);
// Explicitly set mocks
// Use require() because jest.setMock() expects CommonJS exports as a parameter
jest.setMock('jquery', require('./__mocks__/node/jquery'));
jest.setMock('~/lib/utils/axios_utils', require('./__mocks__/gitlab/axios_utils'));
// Tip: jest.setMock(name, exportObj) is equivalent to jest.mock(name, () => exportObj)
jest.setMock('jquery', require('./mocks/node/jquery'));
jest.setMock('~/lib/utils/axios_utils', require('./mocks/gitlab/axios_utils'));
afterEach(() =>
// give Promises a bit more time so they fail the right test
......
import $ from 'jquery';
import axios from '~/lib/utils/axios_utils';
jest.mock('~/lib/utils/axios_utils');
describe('Jest tests', () => {
describe('mock', () => {
it('~/lib/utils/axios_utils', () =>
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать