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

chore(deps-dev): bump jest from 27.5.1 to 28.0.0 #5421

Merged
merged 9 commits into from
Apr 28, 2022

Conversation

dependabot[bot]
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Apr 25, 2022

Bumps jest from 27.5.1 to 28.0.0.

Release notes

Sourced from jest's releases.

v28.0.0

Blog post: https://jestjs.io/blog/2022/04/25/jest-28

Features

  • [babel-jest] Export createTransformer function (#12399)
  • [expect] Expose AsymmetricMatchers, MatcherFunction and MatcherFunctionWithState interfaces (#12363, #12376)
  • [jest-circus] Support error logging before retry (#12201)
  • [jest-circus, jest-jasmine2] Allowed classes and functions as describe and it/test names (#12484)
  • [jest-cli, jest-config] [BREAKING] Remove testURL config, use testEnvironmentOptions.url instead (#10797)
  • [jest-cli, jest-core] Add --shard parameter for distributed parallel test execution (#12546)
  • [jest-cli] [BREAKING] Remove undocumented --timers option (#12572)
  • [jest-config] [BREAKING] Stop shipping jest-environment-jsdom by default (#12354)
  • [jest-config] [BREAKING] Stop shipping jest-jasmine2 by default (#12355)
  • [jest-config, @jest/types] Add ci to GlobalConfig (#12378)
  • [jest-config] [BREAKING] Rename moduleLoader to runtime (#10817)
  • [jest-config] [BREAKING] Rename extraGlobals to sandboxInjectedGlobals (#10817)
  • [jest-config] [BREAKING] Throw an error instead of showing a warning if multiple configs are used (#12510)
  • [jest-config] [BREAKING] Do not normalize long deprecated configuration options preprocessorIgnorePatterns,scriptPreprocessor, setupTestFrameworkScriptFile and testPathDirs (#1251270110)
  • [jest-cli, jest-core] Add --ignoreProjects CLI argument to ignore test suites by project name (#12620)
  • [jest-core] Pass project config to globalSetup/globalTeardown function as second argument (#12440)
  • [jest-core] Stabilize test runners with event emitters (#12641)
  • [jest-core, jest-watcher] [BREAKING] Move TestWatcher class to jest-watcher package (#12652)
  • [jest-core] Allow using Summary Reporter as stand-alone reporter (#12687)
  • [jest-environment-jsdom] [BREAKING] Upgrade jsdom to 19.0.0 (#12290)
  • [jest-environment-jsdom] [BREAKING] Add default browser condition to exportConditions for jsdom environment (#11924)
  • [jest-environment-jsdom] [BREAKING] Pass global config to Jest environment constructor for jsdom environment (#12461)
  • [jest-environment-jsdom] [BREAKING] Second argument context to constructor is mandatory (#12469)
  • [jest-environment-node] [BREAKING] Add default node and node-addon conditions to exportConditions for node environment (#11924)
  • [jest-environment-node] [BREAKING] Pass global config to Jest environment constructor for node environment (#12461)
  • [jest-environment-node] [BREAKING] Second argument context to constructor is mandatory (#12469)
  • [jest-environment-node] Add all available globals to test globals, not just explicit ones (#12642, #12696)
  • [@jest/expect] New module which extends expect with jest-snapshot matchers (#12404, #12410, #12418)
  • [@jest/expect-utils] New module exporting utils for expect (#12323)
  • [@jest/fake-timers] [BREAKING] Rename timers configuration option to fakeTimers (#12572)
  • [@jest/fake-timers] [BREAKING] Allow jest.useFakeTimers() and projectConfig.fakeTimers to take an options bag (#12572)
  • [jest-haste-map] [BREAKING] HasteMap.create now returns a promise (#12008)
  • [jest-haste-map] Add support for dependencyExtractor written in ESM (#12008)
  • [jest-mock] [BREAKING] Rename exported utility types ClassLike, FunctionLike, ConstructorLikeKeys, MethodLikeKeys, PropertyLikeKeys; remove exports of utility types ArgumentsOf, ArgsType, ConstructorArgumentsOf - TS builtin utility types ConstructorParameters and Parameters should be used instead (#12435, #12489)
  • [jest-mock] Improve isMockFunction to infer types of passed function (#12442)
  • [jest-mock] [BREAKING] Improve the usage of jest.fn generic type argument (#12489)
  • [jest-mock] Add support for auto-mocking async generator functions (#11080)
  • [jest-mock] Add contexts member to mock functions (#12601)
  • [@jest/reporters] Add GitHub Actions reporter (#11320, #12658)
  • [@jest/reporters] Pass reporterContext to custom reporter constructors as third argument (#12657)
  • [jest-resolve] [BREAKING] Add support for package.json exports (#11961, #12373)
  • [jest-resolve] Support package self-reference (#12682)
  • [jest-resolve, jest-runtime] Add support for data: URI import and mock (#12392)
  • [jest-resolve, jest-runtime] Add support for async resolver (#11540)
  • [jest-resolve] [BREAKING] Remove browser?: boolean from resolver options, conditions: ['browser'] should be used instead (#12707)

... (truncated)

Changelog

Sourced from jest's changelog.

28.0.0

Features

  • [babel-jest] Export createTransformer function (#12399)
  • [expect] Expose AsymmetricMatchers, MatcherFunction and MatcherFunctionWithState interfaces (#12363, #12376)
  • [jest-circus] Support error logging before retry (#12201)
  • [jest-circus, jest-jasmine2] Allowed classes and functions as describe and it/test names (#12484)
  • [jest-cli, jest-config] [BREAKING] Remove testURL config, use testEnvironmentOptions.url instead (#10797)
  • [jest-cli, jest-core] Add --shard parameter for distributed parallel test execution (#12546)
  • [jest-cli] [BREAKING] Remove undocumented --timers option (#12572)
  • [jest-config] [BREAKING] Stop shipping jest-environment-jsdom by default (#12354)
  • [jest-config] [BREAKING] Stop shipping jest-jasmine2 by default (#12355)
  • [jest-config, @jest/types] Add ci to GlobalConfig (#12378)
  • [jest-config] [BREAKING] Rename moduleLoader to runtime (#10817)
  • [jest-config] [BREAKING] Rename extraGlobals to sandboxInjectedGlobals (#10817)
  • [jest-config] [BREAKING] Throw an error instead of showing a warning if multiple configs are used (#12510)
  • [jest-config] [BREAKING] Do not normalize long deprecated configuration options preprocessorIgnorePatterns,scriptPreprocessor, setupTestFrameworkScriptFile and testPathDirs (#1251270110)
  • [jest-cli, jest-core] Add --ignoreProjects CLI argument to ignore test suites by project name (#12620)
  • [jest-core] Pass project config to globalSetup/globalTeardown function as second argument (#12440)
  • [jest-core] Stabilize test runners with event emitters (#12641)
  • [jest-core, jest-watcher] [BREAKING] Move TestWatcher class to jest-watcher package (#12652)
  • [jest-core] Allow using Summary Reporter as stand-alone reporter (#12687)
  • [jest-environment-jsdom] [BREAKING] Upgrade jsdom to 19.0.0 (#12290)
  • [jest-environment-jsdom] [BREAKING] Add default browser condition to exportConditions for jsdom environment (#11924)
  • [jest-environment-jsdom] [BREAKING] Pass global config to Jest environment constructor for jsdom environment (#12461)
  • [jest-environment-jsdom] [BREAKING] Second argument context to constructor is mandatory (#12469)
  • [jest-environment-node] [BREAKING] Add default node and node-addon conditions to exportConditions for node environment (#11924)
  • [jest-environment-node] [BREAKING] Pass global config to Jest environment constructor for node environment (#12461)
  • [jest-environment-node] [BREAKING] Second argument context to constructor is mandatory (#12469)
  • [jest-environment-node] Add all available globals to test globals, not just explicit ones (#12642, #12696)
  • [@jest/expect] New module which extends expect with jest-snapshot matchers (#12404, #12410, #12418)
  • [@jest/expect-utils] New module exporting utils for expect (#12323)
  • [@jest/fake-timers] [BREAKING] Rename timers configuration option to fakeTimers (#12572)
  • [@jest/fake-timers] [BREAKING] Allow jest.useFakeTimers() and projectConfig.fakeTimers to take an options bag (#12572)
  • [jest-haste-map] [BREAKING] HasteMap.create now returns a promise (#12008)
  • [jest-haste-map] Add support for dependencyExtractor written in ESM (#12008)
  • [jest-mock] [BREAKING] Rename exported utility types ClassLike, FunctionLike, ConstructorLikeKeys, MethodLikeKeys, PropertyLikeKeys; remove exports of utility types ArgumentsOf, ArgsType, ConstructorArgumentsOf - TS builtin utility types ConstructorParameters and Parameters should be used instead (#12435, #12489)
  • [jest-mock] Improve isMockFunction to infer types of passed function (#12442)
  • [jest-mock] [BREAKING] Improve the usage of jest.fn generic type argument (#12489)
  • [jest-mock] Add support for auto-mocking async generator functions (#11080)
  • [jest-mock] Add contexts member to mock functions (#12601)
  • [@jest/reporters] Add GitHub Actions reporter (#11320, #12658)
  • [@jest/reporters] Pass reporterContext to custom reporter constructors as third argument (#12657)
  • [jest-resolve] [BREAKING] Add support for package.json exports (#11961, #12373)
  • [jest-resolve] Support package self-reference (#12682)
  • [jest-resolve, jest-runtime] Add support for data: URI import and mock (#12392)
  • [jest-resolve, jest-runtime] Add support for async resolver (#11540)
  • [jest-resolve] [BREAKING] Remove browser?: boolean from resolver options, conditions: ['browser'] should be used instead (#12707)
  • [jest-resolve] Expose JestResolver, AsyncResolver, SyncResolver, PackageFilter, PathFilter and PackageJSON types (#12707, (#12712)

... (truncated)

Commits

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

@dependabot dependabot bot requested a review from a team as a code owner April 25, 2022 18:46
@dependabot dependabot bot added category: engineering dependencies Pull requests that update a dependency file labels Apr 25, 2022
@dependabot dependabot bot force-pushed the dependabot/npm_and_yarn/jest-28.0.0 branch from a3c809e to 9d0920a Compare April 25, 2022 21:07
Bumps [jest](https://github.com/facebook/jest/tree/HEAD/packages/jest) from 27.5.1 to 28.0.0.
- [Release notes](https://github.com/facebook/jest/releases)
- [Changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/jest/commits/v28.0.0/packages/jest)

---
updated-dependencies:
- dependency-name: jest
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
@dependabot dependabot bot force-pushed the dependabot/npm_and_yarn/jest-28.0.0 branch from 9d0920a to 94ee879 Compare April 25, 2022 21:14
@dbjorge
Copy link
Contributor

dbjorge commented Apr 26, 2022

This required some manual updates. The easy ones were:

  • Jest 28 no longer includes jest-environment-jsdom as an implicit dependency. Our unit and e2e tests both use this, so I've added an explicit dependency for it.
  • Jest 28 adds a new github-actions reporter available by default. This seems like an obvious win, so I went ahead and enabled it.
  • Jest 28 adds native support for a --shard argument; I've replaced the janky manual version our GitHub CI build was using with the new native support. I fixed the off-by-one issue with our sharded job naming while I was here. I'll update the main branch policy accordingly once this PR merges.

The other three were more interesting; I've given them separate comments for ease of linking them.

@dbjorge
Copy link
Contributor

dbjorge commented Apr 26, 2022

Jest 28 tries to use an ESM version of uuid by default

Jest 28 attempts to respect package.json exports fields based on the test environment you're using. This means that for packages that export separate entry points for node vs browser environments, Jest will attempt to use the browser entry point when you're using jest-environment-jsdom and the node entry point when you're using jest-environment-node. This is a good change that we want to use in most cases; it keeps our test environment closer to a real browser environment.

Unfortunately, one of our dependencies (uuid) only provides an ESM implementation (not CommonJS) for browsers, though it provides both ESM and CommonJS versions for node. This comment on uuid#620 summarizes their exports matrix, and uuid#616's discussion has some context on the issue. uuid's package.json indicates that its ESM+browser entry point is what all browser cases should use, so Jest ends up trying to use that even though Jest tries to use a CommonJS+browser entry point where available. This produces hundreds of errors that look something like this:

Full example of an error
  ● Test suite failed to run

    Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.

    Here's what you can do:
     • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
     • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/configuration
    For information about custom transformations, see:
    https://jestjs.io/docs/code-transformation

    Details:

    C:\repos\accessibility-insights-web\node_modules\uuid\dist\esm-browser\index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){export { default as v1 } from './v1.js';
                                                                                      ^^^^^^

    SyntaxError: Unexpected token 'export'

      1 | // Copyright (c) Microsoft Corporation. All rights reserved.
      2 | // Licensed under the MIT License.
    > 3 | import { v4 } from 'uuid';
        |                          ^
      4 |
      5 | export type UUIDGenerator = () => string;
      6 |

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1773:14)
      at Object.<anonymous> (src/common/uid-generator.ts:3:26)

I considered a few options for addressing this:

@dbjorge
Copy link
Contributor

dbjorge commented Apr 26, 2022

jsdom v17 assumes the availability of a global TextEncoder, which jest-environment-jsdom does not provide

Because we updated how we pull in jest-environment-jsdom, we ended up updating the version of jsdom that we use in practice, so we started hitting this not-entirely-new issue. This one is described by jsdom/jsdom#2524 (comment) (the original issue is for a separate-but-related feature request, which was unfortunately hijacked).

The symptom is an error of form ReferenceError: TextEncoder is not defined on a line importing jsdom.

Full example of an error
 FAIL   unit tests  src/tests/unit/tests/injected/visualization/drawer.test.ts
  ● Test suite failed to run

    ReferenceError: TextEncoder is not defined

      1 | // Copyright (c) Microsoft Corporation. All rights reserved.
      2 | // Licensed under the MIT License.
    > 3 | import { JSDOM } from 'jsdom';
        |                              ^
      4 |
      5 | export class TestDocumentCreator {
      6 |     public static createTestDocument(html: string = ''): Document {

      at Object.<anonymous> (node_modules/jsdom/node_modules/whatwg-url/lib/encoding.js:2:21)
      at Object.<anonymous> (node_modules/jsdom/node_modules/whatwg-url/lib/url-state-machine.js:5:34)
      at Object.<anonymous> (node_modules/jsdom/node_modules/whatwg-url/lib/URL-impl.js:2:13)
      at Object.<anonymous> (node_modules/jsdom/node_modules/whatwg-url/lib/URL.js:442:14)
      at Object.<anonymous> (node_modules/jsdom/node_modules/whatwg-url/webidl2js-wrapper.js:3:13)
      at Object.<anonymous> (node_modules/jsdom/node_modules/whatwg-url/index.js:3:34)
      at Object.<anonymous> (node_modules/jsdom/lib/api.js:7:19)
      at Object.<anonymous> (src/tests/unit/common/test-document-creator.ts:3:30)
      at Object.<anonymous> (src/tests/unit/tests/injected/visualization/drawer.test.ts:15:78)

The issue is that we're trying to import jsdom from within a jest-environment-jsdom environment. jsdom uses a global TextEncoder as part of its implementation, but doesn't export one globally. The suggested workaround from the Jest maintainer is to not import jsdom reentrantly, and to instead use jest-environment-node for tests that import jsdom themselves. We don't want to do that; we have some tests that want to import jsdom to create a fresh DOM environment to test in isolation with, but some of our transitive dependencies assume the availability of a global document/window for reasons unimportant to those specific tests. Instead, I worked around this by just re-exporting Node util's TextEncoder as window.TextEncoder in our unit tests' jest-setup.

@dbjorge
Copy link
Contributor

dbjorge commented Apr 26, 2022

Jest 28 forbids describe(SomeThing, ...) for SomeThings without names

In Jest 27, specifying describe(SomeThing, ...) when SomeThing does not have a name (eg, an arrow function) was not an error; it just produced tests where the "SomeThing" that was intended to be filled in at the beginning of a test name was actually filled in as an empty string.

Jest 28 has become more strict about this. Passing a named function or a named class is now explicitly supported, but passing an unnamed thing now produces an error of the form Invalid first argument, <stringified version of Thing>. It must be a named class, named function, number, or string. In practice, this error message is very challenging to parse because is the entire definition of a function, complete with code coverage markers:

Example of one of these errors
FAIL unit tests src/tests/unit/tests/DetailsView/details-view-content.test.tsx
  ● Test suite failed to run

    Invalid first argument, function (props) {
      /* istanbul ignore next */
      cov_7cparukpf().f[1]++;
      var selectedDetailsViewSwitcherNavConfiguration =
      /* istanbul ignore next */
      (cov_7cparukpf().s[20]++, props.deps.getDetailsSwitcherNavConfiguration({
        selectedDetailsViewPivot: props.storeState.visualizationStoreData.selectedDetailsViewPivot
      }));

      /* istanbul ignore next */
      cov_7cparukpf().s[21]++;

      var renderHeader = function () {
        /* istanbul ignore next */
        cov_7cparukpf().f[2]++;
        var storeState =
        /* istanbul ignore next */
        (cov_7cparukpf().s[22]++, props.storeState);
        var visualizationStoreData =
        /* istanbul ignore next */
        (cov_7cparukpf().s[23]++, storeState.visualizationStoreData);

        /* istanbul ignore next */
        cov_7cparukpf().s[24]++;
        return /*#__PURE__*/React.createElement(_interactiveHeader.InteractiveHeader, {
          deps: props.deps,
          selectedPivot: visualizationStoreData.selectedDetailsViewPivot,
          featureFlagStoreData: storeState.featureFlagStoreData,
          tabClosed: props.storeState.tabStoreData.isClosed,
          navMenu: selectedDetailsViewSwitcherNavConfiguration.leftNavHamburgerButton,
          isSideNavOpen: props.isSideNavOpen,
          setSideNavOpen: props.setSideNavOpen,
          narrowModeStatus: props.narrowModeStatus
        });
      };

      /* istanbul ignore next */
      cov_7cparukpf().s[25]++;

      var renderOverlay = function () {
        /* istanbul ignore next */
        cov_7cparukpf().f[3]++;
        var deps =
        /* istanbul ignore next */
        (cov_7cparukpf().s[26]++, props.deps),
            storeState =
        /* istanbul ignore next */
        (cov_7cparukpf().s[27]++, props.storeState);

        /* istanbul ignore next */
        cov_7cparukpf().s[28]++;
        return /*#__PURE__*/React.createElement(_detailsViewOverlay.DetailsViewOverlay, {
          deps: deps,
          previewFeatureFlagsHandler: props.deps.previewFeatureFlagsHandler,
          scopingActionMessageCreator: props.deps.scopingActionMessageCreator,
          inspectActionMessageCreator: props.deps.inspectActionMessageCreator,
          detailsViewStoreData: storeState.detailsViewStoreData,
          scopingStoreData: storeState.scopingPanelStateStoreData,
          featureFlagStoreData: storeState.featureFlagStoreData,
          userConfigurationStoreData: storeState.userConfigurationStoreData
        });
      };

      /* istanbul ignore next */
      cov_7cparukpf().s[29]++;

      var renderDetailsView = function () {
        /* istanbul ignore next */
        cov_7cparukpf().f[4]++;
        var deps =
        /* istanbul ignore next */
        (cov_7cparukpf().s[30]++, props.deps),
            storeState =
        /* istanbul ignore next */
        (cov_7cparukpf().s[31]++, props.storeState);
        var selectedDetailsRightPanelConfiguration =
        /* istanbul ignore next */
        (cov_7cparukpf().s[32]++, props.deps.getDetailsRightPanelConfiguration({
          selectedDetailsViewPivot: storeState.visualizationStoreData.selectedDetailsViewPivot,
          detailsViewRightContentPanel: storeState.detailsViewStoreData.detailsViewRightContentPanel
        }));
        var selectedTest =
        /* istanbul ignore next */
        (cov_7cparukpf().s[33]++, selectedDetailsViewSwitcherNavConfiguration.getSelectedDetailsView(storeState));
        var automatedChecksCardsViewData =
        /* istanbul ignore next */
        (cov_7cparukpf().s[34]++, props.deps.getCardViewData(props.storeState.unifiedScanResultStoreData.rules, props.storeState.unifiedScanResultStoreData.results, props.deps.getCardSelectionViewData(props.storeState.cardSelectionStoreData, props.storeState.unifiedScanResultStoreData, props.deps.isResultHighlightUnavailable)));
        var tabStopRequirementData =
        /* istanbul ignore next */
        (cov_7cparukpf().s[35]++, props.storeState.visualizationScanResultStoreData.tabStops.requirements);
        var needsReviewCardsViewData =
        /* istanbul ignore next */
        (cov_7cparukpf().s[[36](https://github.com/microsoft/accessibility-insights-web/runs/6167262184?check_suite_focus=true#step:7:36)]++, props.deps.getCardViewData(props.storeState.needsReviewScanResultStoreData.rules, props.storeState.needsReviewScanResultStoreData.results, props.deps.getCardSelectionViewData(props.storeState.needsReviewCardSelectionStoreData, props.storeState.needsReviewScanResultStoreData, props.deps.isResultHighlightUnavailable)));
        var targetAppInfo =
        /* istanbul ignore next */
        (cov_7cparukpf().s[[37](https://github.com/microsoft/accessibility-insights-web/runs/6167262184?check_suite_focus=true#step:7:37)]++, {
          name: props.storeState.tabStoreData.title,
          url: props.storeState.tabStoreData.url
        });
        var scanDate =
        /* istanbul ignore next */
        (cov_7cparukpf().s[[38](https://github.com/microsoft/accessibility-insights-web/runs/6167262184?check_suite_focus=true#step:7:38)]++, props.deps.getDateFromTimestamp(props.storeState.unifiedScanResultStoreData.timestamp));
        var scanMetadata =
        /* istanbul ignore next */
        (cov_7cparukpf().s[[39](https://github.com/microsoft/accessibility-insights-web/runs/6167262184?check_suite_focus=true#step:7:39)]++, {
          timespan: {
            scanComplete: scanDate
          },
          targetAppInfo: targetAppInfo,
          toolData: props.storeState.unifiedScanResultStoreData.toolInfo
        });

        /* istanbul ignore next */
        cov_7cparukpf().s[[40](https://github.com/microsoft/accessibility-insights-web/runs/6167262184?check_suite_focus=true#step:7:40)]++;
        return /*#__PURE__*/React.createElement(_detailsViewBody.DetailsViewBody, {
          deps: deps,
          tabStoreData: storeState.tabStoreData,
          tabStopsViewStoreData: storeState.tabStopsViewStoreData,
          assessmentStoreData: storeState.assessmentStoreData,
          pathSnippetStoreData: storeState.pathSnippetStoreData,
          featureFlagStoreData: storeState.featureFlagStoreData,
          selectedTest: selectedTest,
          detailsViewStoreData: storeState.detailsViewStoreData,
          visualizationStoreData: storeState.visualizationStoreData,
          visualizationScanResultData: storeState.visualizationScanResultStoreData,
          visualizationConfigurationFactory: props.deps.visualizationConfigurationFactory,
          assessmentsProvider: props.deps.assessmentsProvider,
          dropdownClickHandler: props.deps.dropdownClickHandler,
          clickHandlerFactory: props.deps.clickHandlerFactory,
          assessmentInstanceTableHandler: props.deps.assessmentInstanceTableHandler,
          issuesTableHandler: props.deps.issuesTableHandler,
          rightPanelConfiguration: selectedDetailsRightPanelConfiguration,
          switcherNavConfiguration: selectedDetailsViewSwitcherNavConfiguration,
          userConfigurationStoreData: storeState.userConfigurationStoreData,
          automatedChecksCardsViewData: automatedChecksCardsViewData,
          needsReviewCardsViewData: needsReviewCardsViewData,
          scanIncompleteWarnings: storeState.unifiedScanResultStoreData.scanIncompleteWarnings,
          scanMetadata: scanMetadata,
          isSideNavOpen: props.isSideNavOpen,
          setSideNavOpen: props.setSideNavOpen,
          narrowModeStatus: props.narrowModeStatus,
          tabStopRequirementData: tabStopRequirementData
        });
      };

      /* istanbul ignore next */
      cov_7cparukpf().s[[41](https://github.com/microsoft/accessibility-insights-web/runs/6167262184?check_suite_focus=true#step:7:41)]++;
      return /*#__PURE__*/React.createElement(React.Fragment, null, renderHeader(), renderDetailsView(), renderOverlay());
    }. It must be a named class, named function, number, or string.

      [49](https://github.com/microsoft/accessibility-insights-web/runs/6167262184?check_suite_focus=true#step:7:49) | import { StoreMocks } from './store-mocks';
      [50](https://github.com/microsoft/accessibility-insights-web/runs/6167262184?check_suite_focus=true#step:7:50) |
    > [51](https://github.com/microsoft/accessibility-insights-web/runs/6167262184?check_suite_focus=true#step:7:51) | describe(DetailsViewContent, () => {
         | ^
      [52](https://github.com/microsoft/accessibility-insights-web/runs/6167262184?check_suite_focus=true#step:7:52) |     const pageTitle = 'DetailsViewContainerTest title';
      [53](https://github.com/microsoft/accessibility-insights-web/runs/6167262184?check_suite_focus=true#step:7:53) |     const pageUrl = 'http://detailsViewContainerTest/url/';
      [54](https://github.com/microsoft/accessibility-insights-web/runs/6167262184?check_suite_focus=true#step:7:54) |     let detailsViewActionMessageCreator: IMock<DetailsViewActionMessageCreator>;

      at Object.describe (src/tests/unit/tests/DetailsView/details-view-content.test.tsx:51:1)

18 of our test files trigger this issue. In every case, the unnamed component in question is a NamedFC React component. The displayName that NamedFC gives these components is just for the benefit of React debugging messages, and doesn't help Jest - these really are 18 test files with test names like renders normally instead of ThingUnderTest renders normally, with an empty string where the component name belongs.

I think the ideal way to resolve this would be to completely remove our NamedFC wrapper and replace it with eslint-plugin-react's display-name and/or function-component-definition rules (with similar settings to what AirBnB uses as of this issue's resolution).

That would be a huge change, though; we have hundreds of components that use NamedFC. I'd want to do a separate PR for that. Instead, this PR just changes the 18 tests in question to use TheNamedFC.displayName; this has the advantage that it will break obviously if we ever do the bigger change.

@dependabot @github
Copy link
Contributor Author

dependabot bot commented on behalf of github Apr 26, 2022

A newer version of jest exists, but since this PR has been edited by someone other than Dependabot I haven't updated it. You'll get a PR for the updated version as normal once this PR is merged.

Copy link
Contributor

@karanbirsingh karanbirsingh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the detailed comments! I agree with your proposed approach for NamedFC components.

@eric-burel
Copy link

eric-burel commented May 3, 2022

Hi, I think I hit issues similar to those mentioned for uuid with Apollo Client: apollographql/apollo-feature-requests#287

I already had some trouble with Next + ESM packages that rely on @apollo/client. Other framework like SvelteKit or Nuxt have the same issue.
Apollo Client doesn't expose an export map, and won't probably until a while for compatibility reasons. I've written a postinstall patch that forcibly adds a map: https://gist.github.com/eric-burel/543bdc809bcc62208deabdeb004db724

This works ok, though I had to extend it slightly to expose all relevant packages for my test to work again. I also had to import gql directly from "graphql-tag" (which is probably for the best anyway).

I just wanted to mention that because we will probably have waves of developers hitting this issue as they update their applications and start using ESM everywhere.

This might make the test way slower though.

(Edit: I've just noticed that this is not a Jest related project but this issue is linked in the migration doc so many people might end up here looking for Jest 28 ESM issues)

@Karrart
Copy link

Karrart commented Jul 9, 2022

Bumps jest from 27.5.1 to 28.0.0.

Release notes

Sourced from jest's releases.

v28.0.0

Blog post: https://jestjs.io/blog/2022/04/25/jest-28

Features

  • [babel-jest] Export createTransformer function (#12399)
  • [expect] Expose AsymmetricMatchers, MatcherFunction and MatcherFunctionWithState interfaces (#12363, #12376)
  • [jest-circus] Support error logging before retry (#12201)
  • [jest-circus, jest-jasmine2] Allowed classes and functions as describe and it/test names (#12484)
  • [jest-cli, jest-config] [BREAKING] Remove testURL config, use testEnvironmentOptions.url instead (#10797)
  • [jest-cli, jest-core] Add --shard parameter for distributed parallel test execution (#12546)
  • [jest-cli] [BREAKING] Remove undocumented --timers option (#12572)
  • [jest-config] [BREAKING] Stop shipping jest-environment-jsdom by default (#12354)
  • [jest-config] [BREAKING] Stop shipping jest-jasmine2 by default (#12355)
  • [jest-config, @jest/types] Add ci to GlobalConfig (#12378)
  • [jest-config] [BREAKING] Rename moduleLoader to runtime (#10817)
  • [jest-config] [BREAKING] Rename extraGlobals to sandboxInjectedGlobals (#10817)
  • [jest-config] [BREAKING] Throw an error instead of showing a warning if multiple configs are used (#12510)
  • [jest-config] [BREAKING] Do not normalize long deprecated configuration options preprocessorIgnorePatterns,scriptPreprocessor, setupTestFrameworkScriptFile and testPathDirs (#1251270110)
  • [jest-cli, jest-core] Add --ignoreProjects CLI argument to ignore test suites by project name (#12620)
  • [jest-core] Pass project config to globalSetup/globalTeardown function as second argument (#12440)
  • [jest-core] Stabilize test runners with event emitters (#12641)
  • [jest-core, jest-watcher] [BREAKING] Move TestWatcher class to jest-watcher package (#12652)
  • [jest-core] Allow using Summary Reporter as stand-alone reporter (#12687)
  • [jest-environment-jsdom] [BREAKING] Upgrade jsdom to 19.0.0 (#12290)
  • [jest-environment-jsdom] [BREAKING] Add default browser condition to exportConditions for jsdom environment (#11924)
  • [jest-environment-jsdom] [BREAKING] Pass global config to Jest environment constructor for jsdom environment (#12461)
  • [jest-environment-jsdom] [BREAKING] Second argument context to constructor is mandatory (#12469)
  • [jest-environment-node] [BREAKING] Add default node and node-addon conditions to exportConditions for node environment (#11924)
  • [jest-environment-node] [BREAKING] Pass global config to Jest environment constructor for node environment (#12461)
  • [jest-environment-node] [BREAKING] Second argument context to constructor is mandatory (#12469)
  • [jest-environment-node] Add all available globals to test globals, not just explicit ones (#12642, #12696)
  • [@jest/expect] New module which extends expect with jest-snapshot matchers (#12404, #12410, #12418)
  • [@jest/expect-utils] New module exporting utils for expect (#12323)
  • [@jest/fake-timers] [BREAKING] Rename timers configuration option to fakeTimers (#12572)
  • [@jest/fake-timers] [BREAKING] Allow jest.useFakeTimers() and projectConfig.fakeTimers to take an options bag (#12572)
  • [jest-haste-map] [BREAKING] HasteMap.create now returns a promise (#12008)
  • [jest-haste-map] Add support for dependencyExtractor written in ESM (#12008)
  • [jest-mock] [BREAKING] Rename exported utility types ClassLike, FunctionLike, ConstructorLikeKeys, MethodLikeKeys, PropertyLikeKeys; remove exports of utility types ArgumentsOf, ArgsType, ConstructorArgumentsOf - TS builtin utility types ConstructorParameters and Parameters should be used instead (#12435, #12489)
  • [jest-mock] Improve isMockFunction to infer types of passed function (#12442)
  • [jest-mock] [BREAKING] Improve the usage of jest.fn generic type argument (#12489)
  • [jest-mock] Add support for auto-mocking async generator functions (#11080)
  • [jest-mock] Add contexts member to mock functions (#12601)
  • [@jest/reporters] Add GitHub Actions reporter (#11320, #12658)
  • [@jest/reporters] Pass reporterContext to custom reporter constructors as third argument (#12657)
  • [jest-resolve] [BREAKING] Add support for package.json exports (#11961, #12373)
  • [jest-resolve] Support package self-reference (#12682)
  • [jest-resolve, jest-runtime] Add support for data: URI import and mock (#12392)
  • [jest-resolve, jest-runtime] Add support for async resolver (#11540)
  • [jest-resolve] [BREAKING] Remove browser?: boolean from resolver options, conditions: ['browser'] should be used instead (#12707)

... (truncated)

Changelog

Sourced from jest's changelog.

28.0.0

Features

  • [babel-jest] Export createTransformer function (#12399)
  • [expect] Expose AsymmetricMatchers, MatcherFunction and MatcherFunctionWithState interfaces (#12363, #12376)
  • [jest-circus] Support error logging before retry (#12201)
  • [jest-circus, jest-jasmine2] Allowed classes and functions as describe and it/test names (#12484)
  • [jest-cli, jest-config] [BREAKING] Remove testURL config, use testEnvironmentOptions.url instead (#10797)
  • [jest-cli, jest-core] Add --shard parameter for distributed parallel test execution (#12546)
  • [jest-cli] [BREAKING] Remove undocumented --timers option (#12572)
  • [jest-config] [BREAKING] Stop shipping jest-environment-jsdom by default (#12354)
  • [jest-config] [BREAKING] Stop shipping jest-jasmine2 by default (#12355)
  • [jest-config, @jest/types] Add ci to GlobalConfig (#12378)
  • [jest-config] [BREAKING] Rename moduleLoader to runtime (#10817)
  • [jest-config] [BREAKING] Rename extraGlobals to sandboxInjectedGlobals (#10817)
  • [jest-config] [BREAKING] Throw an error instead of showing a warning if multiple configs are used (#12510)
  • [jest-config] [BREAKING] Do not normalize long deprecated configuration options preprocessorIgnorePatterns,scriptPreprocessor, setupTestFrameworkScriptFile and testPathDirs (#1251270110)
  • [jest-cli, jest-core] Add --ignoreProjects CLI argument to ignore test suites by project name (#12620)
  • [jest-core] Pass project config to globalSetup/globalTeardown function as second argument (#12440)
  • [jest-core] Stabilize test runners with event emitters (#12641)
  • [jest-core, jest-watcher] [BREAKING] Move TestWatcher class to jest-watcher package (#12652)
  • [jest-core] Allow using Summary Reporter as stand-alone reporter (#12687)
  • [jest-environment-jsdom] [BREAKING] Upgrade jsdom to 19.0.0 (#12290)
  • [jest-environment-jsdom] [BREAKING] Add default browser condition to exportConditions for jsdom environment (#11924)
  • [jest-environment-jsdom] [BREAKING] Pass global config to Jest environment constructor for jsdom environment (#12461)
  • [jest-environment-jsdom] [BREAKING] Second argument context to constructor is mandatory (#12469)
  • [jest-environment-node] [BREAKING] Add default node and node-addon conditions to exportConditions for node environment (#11924)
  • [jest-environment-node] [BREAKING] Pass global config to Jest environment constructor for node environment (#12461)
  • [jest-environment-node] [BREAKING] Second argument context to constructor is mandatory (#12469)
  • [jest-environment-node] Add all available globals to test globals, not just explicit ones (#12642, #12696)
  • [@jest/expect] New module which extends expect with jest-snapshot matchers (#12404, #12410, #12418)
  • [@jest/expect-utils] New module exporting utils for expect (#12323)
  • [@jest/fake-timers] [BREAKING] Rename timers configuration option to fakeTimers (#12572)
  • [@jest/fake-timers] [BREAKING] Allow jest.useFakeTimers() and projectConfig.fakeTimers to take an options bag (#12572)
  • [jest-haste-map] [BREAKING] HasteMap.create now returns a promise (#12008)
  • [jest-haste-map] Add support for dependencyExtractor written in ESM (#12008)
  • [jest-mock] [BREAKING] Rename exported utility types ClassLike, FunctionLike, ConstructorLikeKeys, MethodLikeKeys, PropertyLikeKeys; remove exports of utility types ArgumentsOf, ArgsType, ConstructorArgumentsOf - TS builtin utility types ConstructorParameters and Parameters should be used instead (#12435, #12489)
  • [jest-mock] Improve isMockFunction to infer types of passed function (#12442)
  • [jest-mock] [BREAKING] Improve the usage of jest.fn generic type argument (#12489)
  • [jest-mock] Add support for auto-mocking async generator functions (#11080)
  • [jest-mock] Add contexts member to mock functions (#12601)
  • [@jest/reporters] Add GitHub Actions reporter (#11320, #12658)
  • [@jest/reporters] Pass reporterContext to custom reporter constructors as third argument (#12657)
  • [jest-resolve] [BREAKING] Add support for package.json exports (#11961, #12373)
  • [jest-resolve] Support package self-reference (#12682)
  • [jest-resolve, jest-runtime] Add support for data: URI import and mock (#12392)
  • [jest-resolve, jest-runtime] Add support for async resolver (#11540)
  • [jest-resolve] [BREAKING] Remove browser?: boolean from resolver options, conditions: ['browser'] should be used instead (#12707)
  • [jest-resolve] Expose JestResolver, AsyncResolver, SyncResolver, PackageFilter, PathFilter and PackageJSON types (#12707, (#12712)

... (truncated)

Commits

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

yen-tt pushed a commit to yext/search-ui-react that referenced this pull request Sep 28, 2022
This PR upgrades Jest from v27 to v28. Most of the breaking changes don't affect us, except for two:
- To use the JSDOM test environment, `jest-environment-jsdom` now has to be installed separately
- Jest now has full support for package exports, which can cause problems where file imports are not resolved correctly. Specifically, this is a problem for `uuid`. There is a discussion and proposed solution in this [GitHub issue](microsoft/accessibility-insights-web#5421 (comment)), which I used in this PR. To summarize, the fix is to add a custom resolver that forces Jest to use the CommonJS+node version of `uuid`, but leaves all other resolutions the same

J=SLAP-2123
TEST=auto

See that Jest tests pass.
datenreisender added a commit to NordicSemiconductor/pc-nrfconnect-shared that referenced this pull request Oct 28, 2022
The current version of the package `uuid` doesn't work out of the box
with the new version of Jest, as described in
microsoft/accessibility-insights-web#5421 (comment).

I applied the fix using a `resolver`, as mentioned at the end of the
above link, from
microsoft/accessibility-insights-web@9ad4e61
jbranchaud added a commit to skillrecordings/products that referenced this pull request Jun 21, 2023
kodiakhq bot pushed a commit to skillrecordings/products that referenced this pull request Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: engineering dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants