feat: Use vitest instead of jest, run all the specs anywhere in app/ folder in the CI (#9722)

Due to the pattern `**/specs/*.spec.js` defined in CircleCI, none of the
frontend spec in the folders such as
`specs/<domain-name>/getters.spec.js` were not executed in Circle CI.

This PR fixes the issue, along with the following changes: 
- Use vitest instead of jest
- Remove jest dependancies
- Update tests to work with vitest

---------

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
Pranav
2024-07-10 08:32:16 -07:00
committed by GitHub
parent 9498d1f003
commit 9de8c27368
140 changed files with 1678 additions and 2810 deletions

View File

@@ -1,11 +1,13 @@
import { API } from 'widget/helpers/axios';
import { sendMessage } from 'widget/helpers/utils';
import { actions } from '../../contacts';
const commit = jest.fn();
const dispatch = jest.fn();
jest.mock('widget/helpers/axios');
jest.mock('widget/helpers/utils', () => ({
sendMessage: jest.fn(),
const commit = vi.fn();
const dispatch = vi.fn();
vi.mock('widget/helpers/axios');
vi.mock('widget/helpers/utils', () => ({
sendMessage: vi.fn(),
}));
describe('#actions', () => {
@@ -16,7 +18,9 @@ describe('#actions', () => {
name: 'Adu Thoma',
avatar_url: '',
};
API.patch.mockResolvedValue({ data: { widget_auth_token: 'token' } });
vi.spyOn(API, 'patch').mockResolvedValue({
data: { widget_auth_token: 'token' },
});
await actions.setUser({ commit, dispatch }, { identifier: 1, user });
expect(sendMessage.mock.calls).toEqual([
[{ data: { widgetAuthToken: 'token' }, event: 'setAuthCookie' }],
@@ -37,7 +41,7 @@ describe('#actions', () => {
avatar_url: '',
identifier_hash: '12345',
};
API.patch.mockResolvedValue({ data: { id: 1 } });
vi.spyOn(API, 'patch').mockResolvedValue({ data: { id: 1 } });
await actions.setUser({ commit, dispatch }, { identifier: 1, user });
expect(sendMessage.mock.calls).toEqual([]);
expect(commit.mock.calls).toEqual([]);