Skip to content

Commit

Permalink
fix(TDOPS-5489): PNPM - Prepare scripts-config-jest (#4946)
Browse files Browse the repository at this point in the history
* fix(TDOPS-5489): PNPM - Prepare scripts-config-jest

* add changeset
  • Loading branch information
smouillour authored Oct 20, 2023
1 parent 9a0732e commit e83b74b
Show file tree
Hide file tree
Showing 38 changed files with 105 additions and 284 deletions.
5 changes: 5 additions & 0 deletions .changeset/funny-rockets-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/scripts-config-jest': minor
---

Fix peer dependencies and adapt code to be compatible with pnpm
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import Component from './TreeHeader.component';

jest.mock('react-i18next', () => {
// eslint-disable-next-line global-require
const mockTranslations = require('../../../../test/i18nMock').default;

return mockTranslations();
});

describe('TreeHeader', () => {
it('should render a simple tree header', () => {
const { container } = render(<Component title="myTitle" />);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { render, screen } from '@testing-library/react';
import Component, { getDefaultIcon } from './TreeBranchIcon.component';
jest.unmock('@talend/design-system');
jest.mock('react-i18next', () => {
// eslint-disable-next-line global-require
const mockTranslations = require('../../../../test/i18nMock').default;

return mockTranslations();
});

describe('getDefaultIcon', () => {
it('should return a custom object icon', () => {
Expand Down
57 changes: 0 additions & 57 deletions packages/components/test/i18nMock.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/faceted-search/jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
// DS is mocked by ui-scripts, preventing us to use testing-library getByLabelText & others selectors
jest.unmock('@talend/design-system');
jest.mock('ally.js');
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { BadgeTags } from './BadgeTags.component';
import { BadgeFacetedProvider } from '../../context/badgeFaceted.context';
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { BadgeTags } from './BadgeTags.component';
import { BadgeFacetedProvider } from '../../context/badgeFaceted.context';
import getDefaultT from '../../../translate';

jest.mock('ally.js');

const badgeFacetedContextValue = {
dispatch: jest.fn(),
};
Expand Down
2 changes: 0 additions & 2 deletions packages/forms/src/UIForm/UIForm.container.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import userEvent from '@testing-library/user-event';
import { actions, getMockData, getMockNestedData, initProps } from '../../__mocks__/data';
import UIForm from './UIForm.container';

jest.mock('ally.js');

describe('UIForm container', () => {
let props;
beforeEach(() => {
Expand Down
1 change: 0 additions & 1 deletion packages/forms/src/UIForm/Widget/Widget.component.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { WidgetContext } from '../context';
import Widget from './Widget.component';

jest.unmock('@talend/design-system');
jest.mock('ally.js');

describe('Widget component', () => {
const schema = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import userEvent from '@testing-library/user-event';

import SingleButton from './SingleButton.component';

jest.mock('ally.js');
jest.unmock('@talend/design-system');

describe('SingleButton field', () => {
Expand Down
3 changes: 0 additions & 3 deletions packages/forms/src/UIForm/fields/Code/Code.component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import 'ace-builds/src-noconflict/ext-language_tools';

import Code, { CodeProps } from './Code.component';

// fix cannot read appendChild of null;
jest.mock('ally.js');

declare global {
interface Window {
ReactAce: { default: typeof ReactAce };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import userEvent from '@testing-library/user-event';

import Datalist from './Datalist.component';

jest.mock('ally.js');
jest.unmock('@talend/design-system');

const schema = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { render, screen } from '@testing-library/react';
import DatalistTextMode from './TextMode.component';

jest.mock('ally.js');
jest.unmock('@talend/design-system');
const schema = {
title: 'My List',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { act, render, screen, fireEvent } from '@testing-library/react';
import DateWidget from './Date.component';
jest.mock('ally.js');

jest.unmock('@talend/design-system');

describe('Date widget', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { act, render, screen, fireEvent } from '@testing-library/react';
import DateTimeWidget from './DateTime.component';

jest.mock('ally.js');
jest.unmock('@talend/design-system');

describe('DateTime widget', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { act, render, screen, fireEvent } from '@testing-library/react';
import TimeWidget from './Time.component';

jest.unmock('@talend/design-system');
jest.mock('ally.js');

describe('Time component', () => {
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import userEvent from '@testing-library/user-event';
import EnumerationWidget from './EnumerationWidget';

jest.unmock('@talend/design-system');
jest.mock('ally.js');

describe('EnumerationWidget', () => {
it('should render items', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { screen, render } from '@testing-library/react';
import FieldTemplate from './FieldTemplate.component';

jest.unmock('@talend/design-system');
jest.mock('ally.js');

describe('FieldTemplate', () => {
const defaultProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { screen, render } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import File, { FileWidget, base64Decode } from './File.component';

jest.mock('ally.js');
jest.unmock('@talend/design-system');

describe('File field', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { screen, render } from '@testing-library/react';

jest.mock('ally.js');
jest.unmock('@talend/design-system');

import TextMode from './TextMode.component';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { screen, render } from '@testing-library/react';
import { WidgetContext } from '../../context';
import KeyValue from './KeyValue.component';

jest.mock('ally.js');
jest.unmock('@talend/design-system');

const widgets = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import userEvent from '@testing-library/user-event';
import ListView from './ListView.component';

const NO_RESULT_MESSAGE = 'No results found';
jest.mock('ally.js');

jest.unmock('@talend/design-system');

describe('ListView field', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import userEvent from '@testing-library/user-event';

import MultiSelectTag from './MultiSelectTag.component';

jest.mock('ally.js');
jest.unmock('@talend/design-system');

describe('MultiSelectTag field', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { screen, render } from '@testing-library/react';

import RadioOrSelect from './RadioOrSelect.component';

jest.mock('ally.js');
jest.unmock('@talend/design-system');

describe('RadioOrSelect field', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { screen, render, fireEvent } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import Radios from './Radios.component';

jest.mock('ally.js');
jest.unmock('@talend/design-system');

describe('Radios field', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import userEvent from '@testing-library/user-event';

import ResourcePicker from './ResourcePicker.component';

jest.mock('ally.js');
jest.unmock('@talend/design-system');
jest.mock(
'@talend/react-components/lib/ResourcePicker',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import omit from 'lodash/omit';

import Select from './Select.component';

jest.mock('ally.js');
jest.unmock('@talend/design-system');

describe('Select field', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import userEvent from '@testing-library/user-event';
import Toggle from './Toggle.component';

jest.unmock('@talend/design-system');
jest.mock('ally.js');

describe('Toggle field', () => {
const schema = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { screen, render } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

jest.unmock('@talend/design-system');
jest.mock('ally.js');

function TestArray(props) {
return <div data-testid="array" data-props={JSON.stringify(props, null, 2)} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import userEvent from '@testing-library/user-event';
import ArrayItem from './ArrayItem.component';

jest.unmock('@talend/design-system');
jest.mock('ally.js');

describe('Array Item component', () => {
it('should render control panel with item content', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { screen, render } from '@testing-library/react';
import DefaultArrayTemplate from './DefaultArrayTemplate.component';

jest.unmock('@talend/design-system');
jest.mock('ally.js');

const schema = {
description: 'Tnstructions to fill it',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { WidgetContext } from '../../context';
import widgets from '../../utils/widgets';

jest.unmock('@talend/design-system');
jest.mock('ally.js');

function customTitle(value, schema) {
return `${schema.title}: ${value.firstname} ${value.lastname}`;
Expand Down
1 change: 0 additions & 1 deletion packages/forms/src/rhf/fields/Input/Input.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useForm, FormProvider } from 'react-hook-form';
import Input from './RHFInput.component';

jest.unmock('@talend/design-system');
jest.mock('ally.js');

/* eslint-disable-next-line react/prop-types */
function FormWrapper({ children, onSubmit }) {
Expand Down
1 change: 0 additions & 1 deletion packages/forms/src/rhf/fields/Select/Select.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useForm, FormProvider } from 'react-hook-form';
import Select from './RHFSelect.component';

jest.unmock('@talend/design-system');
jest.mock('ally.js');

/* eslint-disable-next-line react/prop-types */
function FormWrapper({ children, onSubmit }) {
Expand Down
1 change: 0 additions & 1 deletion packages/forms/src/rhf/fields/TextArea/RHFTextArea.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useForm, FormProvider } from 'react-hook-form';
import TextArea from './RHFTextArea.component';

jest.unmock('@talend/design-system');
jest.mock('ally.js');

/* eslint-disable-next-line react/prop-types */
function FormWrapper({ children, onSubmit }) {
Expand Down
4 changes: 2 additions & 2 deletions tools/scripts-config-jest/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ module.exports = {
// stop ignore node_modules transform since d3 and others start to put es6 as main of packages
transformIgnorePatterns: [
// option 2, stop ignore transform on es6 packages
`/node_modules/(?!${d3Pkgs.join(
`node_modules/(?!(?:.pnpm/)?(${d3Pkgs.join(
'|',
)}|internmap|d3-delaunay|delaunator|robust-predicates|@talend/tql/index)`,
)}|internmap|d3-delaunay|delaunator|robust-predicates|@talend/tql/index))`,
// we can't have it twice (double negative patterns cancel each other),
// so you can import addToIgnorePatterns from './utils' to add more pkgs

Expand Down
Loading

0 comments on commit e83b74b

Please sign in to comment.