0

i am testing a typescript react app using jest and react testing library which I'm new to. I introduced d3 and the tests related kept failing and the error was : Jest encountered an unexpected token - SyntaxError: Unexpected token. I found the solution which is to add this config "test": "react-scripts test --transformIgnorePatterns "node_modules/(?!d3)/" " in my package.json file, The problem is when i did this the tests that failed passed but other unrelated tests that used to pass failed, mainly snapshots. This is the errors i'm mainly getting :

 ● Admin services Page › should match snapshot when not loading but not success

    expect(received).toMatchSnapshot()

    Snapshot name: `Admin services Page should match snapshot when not loading but not success 1`

    - Snapshot  - 3
    + Received  + 3

    @@ -101,11 +101,11 @@
                        />
                        <div
                          class=" css-1s2u09g-control"
                        >
                          <div
    -                       class=" css-319lph-ValueContainer"
    +                       class=" css-dlobye-Component"
                          >
                            <div
                              class=" css-14el2xx-placeholder"
                              id="react-select-3-placeholder"
                            >
    @@ -114,11 +114,11 @@
                              >
                                Filter by Teams
                              </span>
                            </div>
                            <div
    -                         class=" css-6j8wv5-Input"
    +                         class=" css-1u4kn00-Component"
                              data-value=""
                            >
                              <input
                                aria-autocomplete="list"
                                aria-describedby="react-select-3-placeholder"
    @@ -137,11 +137,11 @@
                                value=""
                              />
                            </div>
                          </div>
                          <div
    -                       class=" css-1hb7zxy-IndicatorsContainer"
    +                       class=" css-ny0e4k-Component"
                          >
                            <span
                              class=" css-1okebmr-indicatorSeparator"
                            />
                            <div

      85 |             <AdminServicesPage/>
      86 |         );
    > 87 |         expect(container).toMatchSnapshot();
         |                           ^
      88 |     });
      89 |
      90 |     it('should match snapshot when not loading, success and data is empty', function () {

      at Object.<anonymous> (src/pages/admin/services/__tests__/AdminServicesPage.test.tsx:87:27)

So, can I target specific tests with my config ? updating the snapshots is not an option. Is there anything else i can do ?

someone
  • 1
  • 2

0 Answers0