-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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(expect): add exports to satisfy playwright #11816
Conversation
The `playwright` repo uses `expect`, I'd like to bump the version they're using from `26.4.2` to `27.1.0`. Here is the issue which motivated this change: jestjs#11640 You can see my proposed changes here: microsoft/playwright@master...mrienstra:patch-3 I haven't opened a PR for those changes yet, hoping to land this one first. Playwright `npm check-deps` runs `utils/check_deps.js`, which contains a function `allowExternalImport` / `alllowExternalImport` (very recently added in microsoft/playwright#8501), which has a problem with the `expect` `package.json` `exports`, thus the motivation for this PR.
Hi @mrienstra! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If "./build/*": "./build/*.js"
is problematic, this would also resolve the issue with playwright
's utils/check_deps.js
:
"exports": {
".": "./build/index.js",
"./package.json": "./package.json",
"./build/jasmineUtils": "./build/jasmineUtils.js",
"./build/matchers": "./build/matchers.js",
"./build/print": "./build/print.js",
"./build/types": "./build/types.d.ts",
"./build/utils": "./build/utils.js"
},
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
2 similar comments
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Hey! 👋 I don't want to expose stuff from our build folder. I might be convinced to export whatever it is |
import matchers from 'expect/build/matchers'; src/test/matchers/toEqual.ts#L17-L20 import { equals } from 'expect/build/jasmineUtils';
import { iterableEquality } from 'expect/build/utils';
src/test/matchers/toMatchSnapshot.ts#L20 import { SyncExpectationResult } from 'expect/build/types'; src/test/matchers/toMatchText.ts#L17-L20 import {
printReceivedStringContainExpectedResult,
printReceivedStringContainExpectedSubstring
} from 'expect/build/print'; import type { ExpectedAssertionsErrors } from 'expect/build/types'; Summary:
|
Up to sending a PR for that? |
I suspect that's not going to work, given the way src/test/matchers/toEqual.ts#L46-L73 is using
I may need a little assistance (similar PRs to use as a reference?), but certainly down to give it a shot. Lemmie try to get someone from I could be way off here, but I'm starting to think some of the ways @pavelfeldman, @dgozman, @aslushnikov, @yury-s, @JoelEinbinder, @mxschmitt |
They use
Not sure we have similar PRs, but it should be enough to add here: https://github.com/facebook/jest/blob/90d6908492d164392ce8429923e7f0fa17946d2d/packages/expect/src/index.ts#L427-L430 At least type exports, not sure about the utils due to We want |
Ah, right you are! Tried this locally. I'll look into the rest later. Thanks!!! |
Looking ahead to a post-microsoft/playwright#8782 import matchers from 'expect/build/matchers'; src/test/matchers/toEqual.ts#L17-L19 import { iterableEquality } from 'expect/build/utils'; src/test/matchers/toMatchText.ts#L17-L20 import {
printReceivedStringContainExpectedResult,
printReceivedStringContainExpectedSubstring
} from 'expect/build/print'; |
We should definitely export the matchers somehow. Same with printing utils. Not sure about |
…matchers from src/matchers)
… (print utils from src/print)
Codecov Report
@@ Coverage Diff @@
## main #11816 +/- ##
==========================================
- Coverage 68.95% 68.93% -0.02%
==========================================
Files 312 312
Lines 16400 16395 -5
Branches 4750 4750
==========================================
- Hits 11308 11302 -6
- Misses 5065 5066 +1
Partials 27 27
Continue to review full report at Codecov.
|
Re:
[Edit: see below for a different approach I tried in 142f85f] Here are the types for reference. All unique except for export type PrintReceivedStringContainExpectedSubstring = (
received: string,
start: number,
length: number,
) => string;
export type PrintReceivedStringContainExpectedResult = (
received: string,
result: RegExpExecArray | null,
) => string;
export type PrintReceivedArrayContainExpectedItem = (
received: Array<unknown>,
index: number,
) => string;
export type PrintCloseTo = (
receivedDiff: number,
expectedDiff: number,
precision: number,
isNot: boolean,
) => string;
export type PrintExpectedConstructorName = (
label: string,
expected: Function,
) => string;
export type PrintExpectedConstructorNameNot = (
label: string,
expected: Function,
) => string;
export type PrintReceivedConstructorName = (
label: string,
received: Function,
) => string;
export type PrintReceivedConstructorNameNot = (
label: string,
received: Function,
expected: Function,
) => string; |
…t) (print utils from src/print)
Extended Types for these are now all in Made a Downside obviously is more changes. Changes to Because types moved to |
matchers: MatchersObject; | ||
print: PrintObject; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, not a huge fan as it doesn't really belong on the expect
function... We might need to defer this to the next major when we can migrate to ESM style exports (still transpiled to CJS, tho).
One alternative is to create a new package (@jest/expect-utils
or some such) which exports them for public consumption and use within expect
itself. Not a huge fan of that either TBH 😅 So this might need to wait for Jest 28
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough!
After it kicks around the back of your brain a bit more, let me know if you see another way forward. In the meantime, if necessary, consumers can always patch. 🩹
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
The
playwright
repo usesexpect
, I'd like to bump the version they're using from26.4.2
to27.1.0
. Here is the issue which is motivating that version bump: #11640You can see my proposed changes here: microsoft/playwright#8718
That PR is still marked as "draft", hoping to land this one first.
Playwright
npm run check-deps
runsutils/check_deps.js
, which contains a functionallowExternalImport
/alllowExternalImport
(very recently added in microsoft/playwright#8501), which has a problem withexpect
'spackage.json
exports
, thus the motivation for this PR.Context on
exports
: added in PR #9921 and not modified since.