Skip to content

refactor(jest): move jest 27 and under support to separate directory#4847

Merged
rwaskiewicz merged 1 commit intomainfrom
rwaskiewicz/jest/step-1-move-27-infra
Sep 27, 2023
Merged

refactor(jest): move jest 27 and under support to separate directory#4847
rwaskiewicz merged 1 commit intomainfrom
rwaskiewicz/jest/step-1-move-27-infra

Conversation

@rwaskiewicz
Copy link
Member

@rwaskiewicz rwaskiewicz commented Sep 26, 2023

What is the current behavior?

Stencil's Jest infrastructure assumes that the typings used by Stencil internally will match those
used by end-user's projects. This makes it rather difficult to upgrade Jest for both Stencil internally
and to support newer versions of Jest for users.

GitHub Issue Number: N/A

What is the new behavior?

Existing Jest 27 code is moved to a new directory. In this directory, a new "internal" package
is created that declares its own support for @types/jest, breaking the coupling of type
dependencies between Stencil's internal tests and the infrastructure that we build for end users.

Prior to this commit, the typings for Jest are declared in Stencil's root-level package.json and propagate to the testing submodule:

├── src/testing              <- Testing submodule
│   │    index.ts
│   ├── jest                 <- Files in this directory type check against @types/jest@27 in Stencil's root-level node_modules/
│   │   ├── jest-config.ts
│   │   ├── jest-environment.ts
│   │   ├── jest-preprocessor.ts
│   │   ├── jest-runner.ts
│   │   ├── jest-screenshot.ts
│   │   ├── jest-serializer.ts
│   │   ├── jest-setup-test-framework.ts
│   │   └── test/
└── package.json             <- Root-level package.json - A dependency on @types/jest@27 is declared here

Upon applying this commit, that @types/jest coupling is broken with the introduction of a new directory with a separate package.json that declares its own @types/jest dependency:

├── src/testing/jest/
│   └── jest-27-and-under
│       ├── jest-config.ts                 <- All 'jest-*.ts' files type check against @types/jest@27 from the local node_modules/
│       ├── jest-environment.ts
│       ├── jest-preprocessor.ts
│       ├── jest-runner.ts
│       ├── jest-screenshot.ts
│       ├── jest-serializer.ts
│       ├── jest-setup-test-framework.ts
│       ├── node_modules/
│       ├── package.json                    <- A dependency on @types/jest@27 is defined here
│       ├── test
│       └── tsconfig.json
└── package.json                            <- Root-level package.json - A dependency on @types/jest@27 is declared here

Does this introduce a breaking change?

  • Yes
  • No

Testing

This commit is largely a lift and shift operation of existing files. As such, I expect the existing unit tests to pass (especially those for the component starter).

I also manually tested this as follows:

  1. Build the Project from the Stencil project root and generate a tarball:
npm run clean && npm ci && npm run build && npm pack
  1. Test in a component starter
npm init stencil@latest component jest-shift-test \
&& cd $_ \
&& npm i [PATH_TO_TARBALL]
&& npm t

Other information

Jest 28+ Support

This is the first piece of the puzzle (well, technically the second if we count #4666) to support newer versions of Jest. In subsequent PRs, we'll add support for detecting the Jest version, supporting installs of @types/jest for Stencil engineers, and of course, infra for Jest 28+

For Reviewers

It may be beneficial to review this pull request commit-by-commit. You'll notice that each commit has more detail as to what was done in it to give a little better context. In short:

  • Commit 1 - moves existing jest infrastructure to the new directory using git mv (to preserve history)
  • Commit 2 - updates paths in import statements that are affected by the previous move
  • Commit 3 - moves existing jest matchers to the new directory using git mv (to preserve history)
  • Commit 4 - updates paths in import statements that are affected by the previous move
  • Commit 5 - adds package.json that will declare @types/jest
  • Commit 6 - adds @types/jest to commit 5's package.json
  • Commit 7 - fmt the code

Merging

This commit can be merged upon passing all checks + PR approvals. I'll squash it with a more concise version of all the info presented in this PR summary + the commits themselves

Misc

JIRA: STENCIL-951

@github-actions
Copy link
Contributor

--strictNullChecks error report

Typechecking with --strictNullChecks resulted in 1440 errors on this branch.

That's the same number of errors on main, so at least we're not creating new ones!

reports and statistics

Our most error-prone files
Path Error Count
src/dev-server/index.ts 37
src/mock-doc/serialize-node.ts 36
src/dev-server/server-process.ts 32
src/compiler/build/build-stats.ts 27
src/compiler/output-targets/dist-lazy/generate-lazy-module.ts 25
src/compiler/style/test/optimize-css.spec.ts 23
src/runtime/vdom/vdom-render.ts 23
src/testing/puppeteer/puppeteer-element.ts 23
src/compiler/prerender/prerender-main.ts 22
src/runtime/client-hydrate.ts 19
src/screenshot/connector-base.ts 19
src/compiler/config/test/validate-paths.spec.ts 16
src/dev-server/request-handler.ts 15
src/compiler/prerender/prerender-optimize.ts 14
src/compiler/sys/stencil-sys.ts 14
src/compiler/transpile/transpile-module.ts 14
src/runtime/vdom/vdom-annotations.ts 14
src/sys/node/node-sys.ts 14
src/compiler/build/build-finish.ts 13
src/compiler/prerender/prerender-queue.ts 13
Our most common errors
Typescript Error Code Count
TS2345 435
TS2322 412
TS18048 321
TS18047 99
TS2722 38
TS2532 36
TS2531 25
TS2454 15
TS2352 13
TS2769 10
TS2790 10
TS2538 8
TS2344 5
TS2416 4
TS2493 3
TS18046 2
TS2684 1
TS2488 1
TS2464 1
TS2430 1

Unused exports report

There are 12 unused exports on this PR. That's the same number of errors on main, so at least we're not creating new ones!

Unused exports
File Line Identifier
src/runtime/bootstrap-lazy.ts 21 setNonce
src/screenshot/screenshot-fs.ts 18 readScreenshotData
src/testing/testing-utils.ts 198 withSilentWarn
src/utils/index.ts 140 CUSTOM
src/compiler/app-core/app-data.ts 25 BUILD
src/compiler/app-core/app-data.ts 114 Env
src/compiler/app-core/app-data.ts 116 NAMESPACE
src/compiler/fs-watch/fs-watch-rebuild.ts 110 updateCacheFromRebuild
src/compiler/types/validate-primary-package-output-target.ts 62 satisfies
src/compiler/types/validate-primary-package-output-target.ts 62 Record
src/testing/puppeteer/puppeteer-declarations.ts 485 WaitForEventOptions
src/compiler/sys/fetch/write-fetch-success.ts 7 writeFetchSuccessSync

@rwaskiewicz rwaskiewicz marked this pull request as ready for review September 26, 2023 21:01
@rwaskiewicz rwaskiewicz requested a review from a team as a code owner September 26, 2023 21:01
@@ -0,0 +1,14 @@
{
Copy link
Member Author

Choose a reason for hiding this comment

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

See the commit body where I added this file for details behind some of the decisions. Happy to answer questions about this one

@@ -1,3 +0,0 @@
{
"extends": "../../tsconfig.internal.json"
Copy link
Member Author

Choose a reason for hiding this comment

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

This was git mv'ed, but then when I updated the value for 'extends' here, the GH diff algo thinks they're entirely different files

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

Codewise LGTM 👍

The only question I have reading this is whether this has an impact for users updating to the latest Stencil version. If the decoupling requires adding @types/jest to the user dependencies, we might want to have a migration plan. I don't know enough yet to be sure about this.

@rwaskiewicz
Copy link
Member Author

rwaskiewicz commented Sep 27, 2023

@christian-bromann

The only question I have reading this is whether this has an impact for users updating to the latest Stencil version. If the decoupling requires adding @types/jest to the user dependencies, we might want to have a migration plan. I don't know enough yet to be sure about this.

Good point! Stencil actually does this for folks already (assuming they're using Stencil testing infrastructure via stencil test). The quickest way to test this out is to spin up a Stencil component starter and remove @types/jest:

npm init stencil@latest component types-test \
&& cd $_  \ 
&& npm i \
&& npm uninstall @types/jest

Then try to run the tests, which gives us get the following error:

✗ npm t

> types-test@0.0.1 test
> stencil test --spec --e2e

[34:51.0]  @stencil/core
[34:51.2]  v4.3.0 🐫

[ ERROR ]  Please install supported versions of dev dependencies with either npm or yarn.
           npm install --save-dev @types/jest@27.0.3

Copy link
Contributor

@tanner-reits tanner-reits left a comment

Choose a reason for hiding this comment

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

LGTM! Baby steps!

"author": "Ionic Team",
"homepage": "https://stenciljs.com/",
"volta": {
"extends": "../../../../package.json"
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh cool, didn't know you could extend Volta configs

@rwaskiewicz rwaskiewicz added this pull request to the merge queue Sep 27, 2023
@rwaskiewicz rwaskiewicz removed this pull request from the merge queue due to a manual request Sep 27, 2023
Existing Jest 27 code is moved to a new directory. In this directory,
a new "internal" package is created that declares its own support for
`@types/jest`, breaking the coupling of type dependencies between
Stencil's internal tests and the infrastructure that we build for end
users.

Prior to this commit, the typings for Jest are declared in Stencil's
root-level `package.json` and propagate to the `testing` submodule:

```
├── src/testing              <- Testing submodule
│   │    index.ts
│   ├── jest                 <- Files in this directory type check against @types/jest@27 in Stencil's root-level node_modules/
│   │   ├── jest-config.ts
│   │   ├── jest-environment.ts
│   │   ├── jest-preprocessor.ts
│   │   ├── jest-runner.ts
│   │   ├── jest-screenshot.ts
│   │   ├── jest-serializer.ts
│   │   ├── jest-setup-test-framework.ts
│   │   └── test/
└── package.json             <- Root-level package.json - A dependency on @types/jest@27 is declared here
```

Upon applying this commit, that `@types/jest` coupling is broken with
the introduction of a new directory with a separate `package.json` that
declares its own `@types/jest` dependency:
```
├── src/testing/jest/
│   └── jest-27-and-under
│       ├── jest-config.ts                 <- All 'jest-*.ts' files type check against @types/jest@27 from the local node_modules/
│       ├── jest-environment.ts
│       ├── jest-preprocessor.ts
│       ├── jest-runner.ts
│       ├── jest-screenshot.ts
│       ├── jest-serializer.ts
│       ├── jest-setup-test-framework.ts
│       ├── node_modules/
│       ├── package.json                    <- A dependency on @types/jest@27 is defined here
│       ├── test
│       └── tsconfig.json
└── package.json                            <- Root-level package.json - A dependency on @types/jest@27 is declared here
```

when creating this commit, `git mv` was run on existing jest
infrastructure to preserve history wherever possible. in some cases,
paths were updated to account for the directory structure change. this
can cause the git diff to appear as a deletion + creation of a new file
in some cases.

an initial package.json to jest-27-and-under/ was added as a part of
this commit. the package name is intentionally using the `@stencil`
scope, in the event we ever want to spin this out in the future.
the version was defaulted to v1.0.0. the level of effort for it to be
kept in sync with the root level package.json is probably not worth the
effort at this time. although not strictly needed, volta is added to
ensure the same versions of npm/node (moreso the former) are used to
update dependencies.

STENCIL-951
@rwaskiewicz rwaskiewicz force-pushed the rwaskiewicz/jest/step-1-move-27-infra branch from 2b189d7 to cbebfd0 Compare September 27, 2023 19:19
@rwaskiewicz rwaskiewicz added this pull request to the merge queue Sep 27, 2023
Merged via the queue into main with commit 84400e6 Sep 27, 2023
@rwaskiewicz rwaskiewicz deleted the rwaskiewicz/jest/step-1-move-27-infra branch September 27, 2023 19:52
rwaskiewicz added a commit that referenced this pull request Oct 2, 2023
add a new abstraction layer to stencil's jest testing
configuration/running such that the version of jest is detected when
jest is run. based on the version that is detected, defer to the correct
piece of versioned infrastructure to setup and run tests.

in #4847, the directory
structure of the testing submodule was updated to look something like:
```
├── src/testing/jest/
│   └── jest-27-and-under
│       ├── jest-config.ts                 <- All 'jest-*.ts' files type check against @types/jest@27 from the local node_modules/
│       ├── jest-environment.ts
│       ├── jest-preprocessor.ts
│       ├── jest-runner.ts
│       ├── jest-screenshot.ts
│       ├── jest-serializer.ts
│       ├── jest-setup-test-framework.ts
│       ├── node_modules/
│       ├── package.json                    <- A dependency on @types/jest@27 is defined here
│       ├── test
│       └── tsconfig.json
└── package.json                            <- Root-level package.json - A dependency on @types/jest@27 is declared here
```

this commit introduces the following infrastructue to dispatch to
jest-27-and-under at runtime:

- `jest-adapter` - a file containing a base class to define the API by
which version-specific implementations can be loaded. a jest
v27-specific implemnetation is included as well
- `jest-stencil-connector` - performs the:
    - detection of the current version of jest
    - dispatching to the correct infrastructure
- `jest-apis` - a file containing typings specific to ambiguous jest
  typings

the end result of this commit should be nothing to the end user (for
now). this work shall be used to help support jest v28+ in the near
future (dispatching the the correct version)
rwaskiewicz added a commit that referenced this pull request Oct 2, 2023
add a new abstraction layer to stencil's jest testing
configuration/running such that the version of jest is detected when
jest is run. based on the version that is detected, defer to the correct
piece of versioned infrastructure to setup and run tests.

in #4847, the directory
structure of the testing submodule was updated to look something like:
```
├── src/testing/jest/
│   └── jest-27-and-under
│       ├── jest-config.ts                 <- All 'jest-*.ts' files type check against @types/jest@27 from the local node_modules/
│       ├── jest-environment.ts
│       ├── jest-preprocessor.ts
│       ├── jest-runner.ts
│       ├── jest-screenshot.ts
│       ├── jest-serializer.ts
│       ├── jest-setup-test-framework.ts
│       ├── node_modules/
│       ├── package.json                    <- A dependency on @types/jest@27 is defined here
│       ├── test
│       └── tsconfig.json
└── package.json                            <- Root-level package.json - A dependency on @types/jest@27 is declared here
```

this commit introduces the following infrastructue to dispatch to
jest-27-and-under at runtime:

- `jest-adapter` - a file containing a base class to define the API by
which version-specific implementations can be loaded. a jest
v27-specific implemnetation is included as well
- `jest-stencil-connector` - performs the:
    - detection of the current version of jest
    - dispatching to the correct infrastructure
- `jest-apis` - a file containing typings specific to ambiguous jest
  typings

the end result of this commit should be nothing to the end user (for
now). this work shall be used to help support jest v28+ in the near
future (dispatching the the correct version)
rwaskiewicz added a commit that referenced this pull request Oct 3, 2023
add a new abstraction layer to stencil's jest testing
configuration/running such that the version of jest is detected when
jest is run. based on the version that is detected, defer to the
correct piece of versioned infrastructure to setup and run tests.

in #4847, the directory
structure of the testing submodule was updated to look something like:
```
├── src/testing/jest/
│   └── jest-27-and-under
│       ├── jest-config.ts
│       ├── jest-environment.ts
│       ├── jest-preprocessor.ts
│       ├── jest-runner.ts
│       ├── jest-screenshot.ts
│       ├── jest-serializer.ts
│       ├── jest-setup-test-framework.ts
│       ├── node_modules/
│       ├── package.json
│       └── test
└── package.json
```

this commit introduces the following infrastructue to dispatch to
jest-27-and-under at runtime:

```diff
  ├── src/testing/jest/
  │   └── jest-27-and-under
  │       ├── jest-config.ts
  │       ├── jest-environment.ts
+ │       ├── jest-facade.ts                  <- Implements base class in `jest-adapter.ts`
  │       ├── jest-preprocessor.ts
  │       ├── jest-runner.ts
  │       ├── jest-screenshot.ts
  │       ├── jest-serializer.ts
  │       ├── jest-setup-test-framework.ts
  │       ├── node_modules/
  │       ├── package.json
  │       └── test
+ ├── jest-adapter.ts                         <- Base class all `jest-facade` implementations should follow
+ ├── jest-apis.ts                            <- Interactions with Jest prior to knowing the version
+ ├── jest-stencil-connector.ts               <- Routes Jest logic through the correct `jest-facade` implementation
  └── package.json
```

Where:
- `jest-adapter` - a file containing a base class to define the API by
which version-specific implementations can be loaded. a jest
v27-specific implementation is included as well in `jest-27-and-under/`
- `jest-stencil-connector` - performs the detection of the current
version of jest - dispatching to the correct infrastructure via
`jest-facade` implementations
- `jest-apis` - a file containing typings for cases where the jest
typings are ambiguous, particularly for when we do not know what the
current version of jest is (yet)

the end result of this commit should be nothing to the end user (for
now). this work shall be used to help support jest v28+ in the near
future (dispatching the the correct version)
rwaskiewicz added a commit that referenced this pull request Oct 3, 2023
update the cspell configuration to ignore all node_modules directories.
when we introduced new `jest`-version subdirectories in #4847,
we failed to update cspell's configuration. as a result, cspell would
run against the `node_modules` directory in
`src/testing/jest/jest-27-and-under` (e.g. `npm run spellcheck`). this
change excludes _all_ `node_modules` cspell's eyes
rwaskiewicz added a commit that referenced this pull request Oct 3, 2023
one consequence of moving to the design laid out in
#4847 is that there are now
`package.json` file(s) that:
- define jest dependencies that are not used by stencil's own internal
  testing
- do not have their dependencies installed when we run `npm ci` (or
  equivalent)

this commit introduces a small shell script that iterates over all jest
subdirectories (currently just one, `jest-27-and-under`) and runs `npm
ci`. this ensures that these dependencies are installed/up to date when
working with stencil
github-merge-queue bot pushed a commit that referenced this pull request Oct 4, 2023
update the cspell configuration to ignore all node_modules directories.
when we introduced new `jest`-version subdirectories in #4847,
we failed to update cspell's configuration. as a result, cspell would
run against the `node_modules` directory in
`src/testing/jest/jest-27-and-under` (e.g. `npm run spellcheck`). this
change excludes _all_ `node_modules` cspell's eyes
rwaskiewicz added a commit that referenced this pull request Oct 5, 2023
add a new abstraction layer to stencil's jest testing
configuration/running such that the version of jest is detected when
jest is run. based on the version that is detected, defer to the
correct piece of versioned infrastructure to setup and run tests.

in #4847, the directory
structure of the testing submodule was updated to look something like:
```
├── src/testing/jest/
│   └── jest-27-and-under
│       ├── jest-config.ts
│       ├── jest-environment.ts
│       ├── jest-preprocessor.ts
│       ├── jest-runner.ts
│       ├── jest-screenshot.ts
│       ├── jest-serializer.ts
│       ├── jest-setup-test-framework.ts
│       ├── node_modules/
│       ├── package.json
│       └── test
└── package.json
```

this commit introduces the following infrastructue to dispatch to
jest-27-and-under at runtime:

```diff
  ├── src/testing/jest/
  │   └── jest-27-and-under
  │       ├── jest-config.ts
  │       ├── jest-environment.ts
+ │       ├── jest-facade.ts                  <- Implements base class in `jest-adapter.ts`
  │       ├── jest-preprocessor.ts
  │       ├── jest-runner.ts
  │       ├── jest-screenshot.ts
  │       ├── jest-serializer.ts
  │       ├── jest-setup-test-framework.ts
  │       ├── node_modules/
  │       ├── package.json
  │       └── test
+ ├── jest-adapter.ts                         <- Base class all `jest-facade` implementations should follow
+ ├── jest-apis.ts                            <- Interactions with Jest prior to knowing the version
+ ├── jest-stencil-connector.ts               <- Routes Jest logic through the correct `jest-facade` implementation
  └── package.json
```

Where:
- `jest-adapter` - a file containing a base class to define the API by
which version-specific implementations can be loaded. a jest
v27-specific implementation is included as well in `jest-27-and-under/`
- `jest-stencil-connector` - performs the detection of the current
version of jest - dispatching to the correct infrastructure via
`jest-facade` implementations
- `jest-apis` - a file containing typings for cases where the jest
typings are ambiguous, particularly for when we do not know what the
current version of jest is (yet)

the end result of this commit should be nothing to the end user (for
now). this work shall be used to help support jest v28+ in the near
future (dispatching the the correct version)
rwaskiewicz added a commit that referenced this pull request Oct 5, 2023
one consequence of moving to the design laid out in
#4847 is that there are now
`package.json` file(s) that:
- define jest dependencies that are not used by stencil's own internal
  testing
- do not have their dependencies installed when we run `npm ci` (or
  equivalent)

this commit introduces a small shell script that iterates over all jest
subdirectories (currently just one, `jest-27-and-under`) and runs `npm
ci`. this ensures that these dependencies are installed/up to date when
working with stencil
rwaskiewicz added a commit that referenced this pull request Oct 5, 2023
add a new abstraction layer to stencil's jest testing
configuration/running such that the version of jest is detected when
jest is run. based on the version that is detected, defer to the
correct piece of versioned infrastructure to setup and run tests.

in #4847, the directory
structure of the testing submodule was updated to look something like:
```
├── src/testing/jest/
│   └── jest-27-and-under
│       ├── jest-config.ts
│       ├── jest-environment.ts
│       ├── jest-preprocessor.ts
│       ├── jest-runner.ts
│       ├── jest-screenshot.ts
│       ├── jest-serializer.ts
│       ├── jest-setup-test-framework.ts
│       ├── node_modules/
│       ├── package.json
│       └── test
└── package.json
```

this commit introduces the following infrastructue to dispatch to
jest-27-and-under at runtime:

```diff
  ├── src/testing/jest/
  │   └── jest-27-and-under
  │       ├── jest-config.ts
  │       ├── jest-environment.ts
+ │       ├── jest-facade.ts                  <- Implements base class in `jest-adapter.ts`
  │       ├── jest-preprocessor.ts
  │       ├── jest-runner.ts
  │       ├── jest-screenshot.ts
  │       ├── jest-serializer.ts
  │       ├── jest-setup-test-framework.ts
  │       ├── node_modules/
  │       ├── package.json
  │       └── test
+ ├── jest-adapter.ts                         <- Base class all `jest-facade` implementations should follow
+ ├── jest-apis.ts                            <- Interactions with Jest prior to knowing the version
+ ├── jest-stencil-connector.ts               <- Routes Jest logic through the correct `jest-facade` implementation
  └── package.json
```

Where:
- `jest-adapter` - a file containing a base class to define the API by
which version-specific implementations can be loaded. a jest
v27-specific implementation is included as well in `jest-27-and-under/`
- `jest-stencil-connector` - performs the detection of the current
version of jest - dispatching to the correct infrastructure via
`jest-facade` implementations
- `jest-apis` - a file containing typings for cases where the jest
typings are ambiguous, particularly for when we do not know what the
current version of jest is (yet)

the end result of this commit should be nothing to the end user (for
now). this work shall be used to help support jest v28+ in the near
future (dispatching the the correct version)
rwaskiewicz added a commit that referenced this pull request Oct 5, 2023
one consequence of moving to the design laid out in
#4847 is that there are now
`package.json` file(s) that:
- define jest dependencies that are not used by stencil's own internal
  testing
- do not have their dependencies installed when we run `npm ci` (or
  equivalent)

this commit introduces a small shell script that iterates over all jest
subdirectories (currently just one, `jest-27-and-under`) and runs `npm
ci`. this ensures that these dependencies are installed/up to date when
working with stencil
rwaskiewicz added a commit that referenced this pull request Oct 6, 2023
add a new abstraction layer to stencil's jest testing
configuration/running such that the version of jest is detected when
jest is run. based on the version that is detected, defer to the
correct piece of versioned infrastructure to setup and run tests.

in #4847, the directory
structure of the testing submodule was updated to look something like:
```
├── src/testing/jest/
│   └── jest-27-and-under
│       ├── jest-config.ts
│       ├── jest-environment.ts
│       ├── jest-preprocessor.ts
│       ├── jest-runner.ts
│       ├── jest-screenshot.ts
│       ├── jest-serializer.ts
│       ├── jest-setup-test-framework.ts
│       ├── node_modules/
│       ├── package.json
│       └── test
└── package.json
```

this commit introduces the following infrastructue to dispatch to
jest-27-and-under at runtime:

```diff
  ├── src/testing/jest/
  │   └── jest-27-and-under
  │       ├── jest-config.ts
  │       ├── jest-environment.ts
+ │       ├── jest-facade.ts                  <- Implements base class in `jest-adapter.ts`
  │       ├── jest-preprocessor.ts
  │       ├── jest-runner.ts
  │       ├── jest-screenshot.ts
  │       ├── jest-serializer.ts
  │       ├── jest-setup-test-framework.ts
  │       ├── node_modules/
  │       ├── package.json
  │       └── test
+ ├── jest-adapter.ts                         <- Base class all `jest-facade` implementations should follow
+ ├── jest-apis.ts                            <- Interactions with Jest prior to knowing the version
+ ├── jest-stencil-connector.ts               <- Routes Jest logic through the correct `jest-facade` implementation
  └── package.json
```

Where:
- `jest-adapter` - a file containing a base class to define the API by
which version-specific implementations can be loaded. a jest
v27-specific implementation is included as well in `jest-27-and-under/`
- `jest-stencil-connector` - performs the detection of the current
version of jest - dispatching to the correct infrastructure via
`jest-facade` implementations
- `jest-apis` - a file containing typings for cases where the jest
typings are ambiguous, particularly for when we do not know what the
current version of jest is (yet)

the end result of this commit should be nothing to the end user (for
now). this work shall be used to help support jest v28+ in the near
future (dispatching the the correct version)
rwaskiewicz added a commit that referenced this pull request Oct 11, 2023
add a new abstraction layer to stencil's jest testing
configuration/running such that the version of jest is detected when
jest is run. based on the version that is detected, defer to the
correct piece of versioned infrastructure to setup and run tests.

in #4847, the directory
structure of the testing submodule was updated to look something like:
```
├── src/testing/jest/
│   └── jest-27-and-under
│       ├── jest-config.ts
│       ├── jest-environment.ts
│       ├── jest-preprocessor.ts
│       ├── jest-runner.ts
│       ├── jest-screenshot.ts
│       ├── jest-serializer.ts
│       ├── jest-setup-test-framework.ts
│       ├── node_modules/
│       ├── package.json
│       └── test
└── package.json
```

this commit introduces the following infrastructue to dispatch to
jest-27-and-under at runtime:

```diff
  ├── src/testing/jest/
  │   └── jest-27-and-under
  │       ├── jest-config.ts
  │       ├── jest-environment.ts
+ │       ├── jest-facade.ts                  <- Implements interface in `../jest-adapter.ts`
  │       ├── jest-preprocessor.ts
  │       ├── jest-runner.ts
  │       ├── jest-screenshot.ts
  │       ├── jest-serializer.ts
  │       ├── jest-setup-test-framework.ts
  │       ├── node_modules/
  │       ├── package.json
  │       └── test
+ ├── jest-apis.ts                            <- Interactions with Jest prior to knowing the version
+ ├── jest-facade.ts                          <- Interface  all `jest-facade` implementations should follow
+ ├── jest-stencil-connector.ts               <- Routes Jest logic through the correct `jest-facade` implementation
  └── package.json
```

Where:
- `jest-stencil-connector` - performs the detection of the current
version of jest - dispatching to the correct infrastructure via
`jest-facade` implementations
- `jest-facade.ts` - a file containing an interface to define the API by
which version-specific implementation can be loaded. the first
implementation for jest 27 and under is included in `jest-27-and-under/`
- `jest-apis` - a file containing typings for cases where the jest
typings are ambiguous, particularly for when we do not know what the
current version of jest is (yet)

the end result of this commit should be nothing to the end user (for
now). this work shall be used to help support jest v28+ in the near
future (dispatching the the correct version)
github-merge-queue bot pushed a commit that referenced this pull request Oct 11, 2023
add a new abstraction layer to stencil's jest testing
configuration/running such that the version of jest is detected when
jest is run. based on the version that is detected, defer to the
correct piece of versioned infrastructure to setup and run tests.

in #4847, the directory
structure of the testing submodule was updated to look something like:
```
├── src/testing/jest/
│   └── jest-27-and-under
│       ├── jest-config.ts
│       ├── jest-environment.ts
│       ├── jest-preprocessor.ts
│       ├── jest-runner.ts
│       ├── jest-screenshot.ts
│       ├── jest-serializer.ts
│       ├── jest-setup-test-framework.ts
│       ├── node_modules/
│       ├── package.json
│       └── test
└── package.json
```

this commit introduces the following infrastructue to dispatch to
jest-27-and-under at runtime:

```diff
  ├── src/testing/jest/
  │   └── jest-27-and-under
  │       ├── jest-config.ts
  │       ├── jest-environment.ts
+ │       ├── jest-facade.ts                  <- Implements interface in `../jest-adapter.ts`
  │       ├── jest-preprocessor.ts
  │       ├── jest-runner.ts
  │       ├── jest-screenshot.ts
  │       ├── jest-serializer.ts
  │       ├── jest-setup-test-framework.ts
  │       ├── node_modules/
  │       ├── package.json
  │       └── test
+ ├── jest-apis.ts                            <- Interactions with Jest prior to knowing the version
+ ├── jest-facade.ts                          <- Interface  all `jest-facade` implementations should follow
+ ├── jest-stencil-connector.ts               <- Routes Jest logic through the correct `jest-facade` implementation
  └── package.json
```

Where:
- `jest-stencil-connector` - performs the detection of the current
version of jest - dispatching to the correct infrastructure via
`jest-facade` implementations
- `jest-facade.ts` - a file containing an interface to define the API by
which version-specific implementation can be loaded. the first
implementation for jest 27 and under is included in `jest-27-and-under/`
- `jest-apis` - a file containing typings for cases where the jest
typings are ambiguous, particularly for when we do not know what the
current version of jest is (yet)

the end result of this commit should be nothing to the end user (for
now). this work shall be used to help support jest v28+ in the near
future (dispatching the the correct version)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants