Skip to content
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

Speedup frontend tests #1326

Merged
merged 1 commit into from
Apr 13, 2022
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
1 change: 0 additions & 1 deletion frontend/app/components/auth-panel/auth-panel.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { h } from 'preact';
import { mount } from 'enzyme';
import createMockStore from 'redux-mock-store';
import { Middleware } from 'redux';
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/components/auth/auth.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import '@testing-library/jest-dom';
import { h } from 'preact';

import { fireEvent, waitFor, screen } from '@testing-library/preact';
import { render } from 'tests/utils';

Expand Down
1 change: 0 additions & 1 deletion frontend/app/components/auth/components/oauth.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { h } from 'preact';
import { render } from 'tests/utils';
import { BASE_URL } from 'common/constants.config';

Expand Down
1 change: 0 additions & 1 deletion frontend/app/components/avatar/avatar.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import '@testing-library/jest-dom';
import { h } from 'preact';
import { render } from '@testing-library/preact';

import { Avatar } from './avatar';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { h } from 'preact';
import { mount } from 'enzyme';
import { act } from 'preact/test-utils';
import { Provider } from 'react-redux';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { h } from 'preact';
import { shallow } from 'enzyme';

import { SubscribeByRSS, createSubscribeUrl } from '.';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { h } from 'preact';
import { shallow } from 'enzyme';

import { user, anonymousUser } from '__stubs__/user';
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/components/comment/comment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ export class Comment extends Component<CommentProps, State> {
return controls;
};

render(props: CommentProps, state: State) {
render(props: CommentProps, state: State): JSX.Element {
const isAdmin = this.isAdmin();
const isGuest = this.isGuest();
const isCurrentUser = this.isCurrentUser();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { h } from 'preact';
import '@testing-library/jest-dom';
import { render } from 'tests/utils';
import { Counter } from '.';
Expand Down
1 change: 0 additions & 1 deletion frontend/app/components/profile/profile.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { h } from 'preact';
import '@testing-library/jest-dom';
import { waitFor } from '@testing-library/preact';
import { fireEvent } from '@testing-library/dom';
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/components/select/select.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '@testing-library/jest-dom';
import { fireEvent } from '@testing-library/preact';
import { h } from 'preact';

import { render } from 'tests/utils';
import { Select } from './select';

Expand Down
1 change: 0 additions & 1 deletion frontend/app/components/sort-picker.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import '@testing-library/jest-dom';
import { fireEvent, waitFor } from '@testing-library/preact';
import { h } from 'preact';

import { render } from 'tests/utils';
import * as commentsActions from 'store/comments/actions';
Expand Down
26 changes: 19 additions & 7 deletions frontend/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
module.exports = {
transform: {
'^.+\\.tsx?$': 'ts-jest',
'^.+\\.jsx?$': 'babel-jest',
'^.+\\.(t|j)sx?$': [
'@swc/jest',
{
jsc: {
parser: {
syntax: 'typescript',
tsx: true,
decorators: false,
},
target: 'es2016',
transform: {
react: {
runtime: 'automatic',
importSource: 'preact',
},
},
},
},
],
},
moduleDirectories: ['node_modules', 'app'],
moduleNameMapper: {
Expand Down Expand Up @@ -32,9 +49,4 @@ module.exports = {
'!app/utils/loadLocale.ts',
'!app/tests',
],
globals: {
'ts-jest': {
babelConfig: true,
},
},
};
Loading