From 8690547dae9661434c89fd0f8baa99f361028d0c Mon Sep 17 00:00:00 2001 From: Anna Wen <54281166+annawen1@users.noreply.github.com> Date: Mon, 9 Dec 2024 13:08:46 -0500 Subject: [PATCH] chore: point to babelrc from jest config --- packages/react/jest.config.js | 2 +- packages/react/package.json | 4 +- .../__tests__/ExampleButton-snapshot.tsx | 10 -- .../__tests__/ExampleButton-test.js | 5 + ...ot.tsx.snap => ExampleButton-test.js.snap} | 2 +- yarn.lock | 118 +++++++++--------- 6 files changed, 71 insertions(+), 70 deletions(-) delete mode 100644 packages/react/src/components/ExampleButton/__tests__/ExampleButton-snapshot.tsx rename packages/react/src/components/ExampleButton/__tests__/__snapshots__/{ExampleButton-snapshot.tsx.snap => ExampleButton-test.js.snap} (63%) diff --git a/packages/react/jest.config.js b/packages/react/jest.config.js index 208056e0..826ce989 100644 --- a/packages/react/jest.config.js +++ b/packages/react/jest.config.js @@ -7,7 +7,7 @@ module.exports = { moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], transform: { '^.+\\.(ts|tsx)$': 'ts-jest', - '^.+\\.(js|jsx)$': 'babel-jest', + '^.+\\.(js|jsx)$': ['babel-jest', { configFile: './.babelrc' }], }, setupFilesAfterEnv: ['/jest.setup.ts'], diff --git a/packages/react/package.json b/packages/react/package.json index 1f74cebd..9d905a9f 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -2,7 +2,6 @@ "name": "@carbon/labs-react-components", "version": "0.0.0", "private": true, - "type": "module", "description": "Carbon Labs React components", "license": "Apache-2.0", "repository": "https://github.com/carbon-design-system/carbon-labs", @@ -12,7 +11,8 @@ "scripts": { "storybook": "storybook dev -p 3000", "build-storybook": "storybook build", - "test": "jest" + "test": "jest", + "test:updateSnapshot": "jest -u" }, "browserslist": { "production": [ diff --git a/packages/react/src/components/ExampleButton/__tests__/ExampleButton-snapshot.tsx b/packages/react/src/components/ExampleButton/__tests__/ExampleButton-snapshot.tsx deleted file mode 100644 index 0fbdcfb6..00000000 --- a/packages/react/src/components/ExampleButton/__tests__/ExampleButton-snapshot.tsx +++ /dev/null @@ -1,10 +0,0 @@ -// Component.test.tsx -import { render } from '@testing-library/react'; -import {ExampleButton} from '../components/ExampleButton'; -import React from 'react'; -describe('YourComponent', () => { - it('should match snapshot', () => { - const { container } = render(); - expect(container).toMatchSnapshot(); - }); -}); \ No newline at end of file diff --git a/packages/react/src/components/ExampleButton/__tests__/ExampleButton-test.js b/packages/react/src/components/ExampleButton/__tests__/ExampleButton-test.js index 5c837847..3a86cb5a 100644 --- a/packages/react/src/components/ExampleButton/__tests__/ExampleButton-test.js +++ b/packages/react/src/components/ExampleButton/__tests__/ExampleButton-test.js @@ -7,6 +7,11 @@ import { ExampleButton } from '../components/ExampleButton'; jest.mock('./button.scss', () => ({})); describe('ExampleButton', () => { describe('renders as expected - Component API', () => { + it('should match snapshot', () => { + const { container } = render(); + expect(container).toMatchSnapshot(); + }); + it('renders a button element', () => { render(); expect(screen.getByRole('button')).toBeInTheDocument(); diff --git a/packages/react/src/components/ExampleButton/__tests__/__snapshots__/ExampleButton-snapshot.tsx.snap b/packages/react/src/components/ExampleButton/__tests__/__snapshots__/ExampleButton-test.js.snap similarity index 63% rename from packages/react/src/components/ExampleButton/__tests__/__snapshots__/ExampleButton-snapshot.tsx.snap rename to packages/react/src/components/ExampleButton/__tests__/__snapshots__/ExampleButton-test.js.snap index a3fddd69..498a0607 100644 --- a/packages/react/src/components/ExampleButton/__tests__/__snapshots__/ExampleButton-snapshot.tsx.snap +++ b/packages/react/src/components/ExampleButton/__tests__/__snapshots__/ExampleButton-test.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`YourComponent should match snapshot 1`] = ` +exports[`ExampleButton renders as expected - Component API should match snapshot 1`] = `