fix: Align Jasmine typing + support jasmine asymetrics matchers + other types fixes#2018
fix: Align Jasmine typing + support jasmine asymetrics matchers + other types fixes#2018dprevost-LMI wants to merge 52 commits into
Conversation
|
@dprevost-LMI thanks for this effort, let me know the status of this and when I can review. |
8ac2038 to
4648bd6
Compare
34cb319 to
b864314
Compare
b864314 to
5bb0b0c
Compare
Also, added framework plugin to error focus tests
@christian-bromann I reviewed it thoroughly following the latest release and ensured it works with the latest wdio, so it's fully ready for you to review! |
b129c66 to
fa34827
Compare
Greptile SummaryThis PR aligns the Jasmine framework typing with the actual runtime behavior of
Confidence Score: 3/5The runtime logic change in Two independent defects are introduced:
|
| Filename | Overview |
|---|---|
| src/utils.ts | Adds Jasmine asymmetric matcher support via new helper functions; compareText updated correctly, but compareTextWithArray still accesses .sample directly for the ignoreCase path, breaking Jasmine matchers in array comparisons. |
| jasmine-wdio-expect-async.d.ts | Adds JasmineExpect interface, JasmineSyncMatchers mapped type, and withContext support; correctly replaces old Expect augmentation with the new Jasmine-specific type structure. |
| jasmine.d.ts | Simplified to only augment AsyncMatchers with WDIO custom matchers; snapshot matcher overrides removed. |
| types/expect-webdriverio.d.ts | Adds JasmineAsymmetricMatcher<R> global type; separates Matchers from ExpectLibMatchers in MatchersAndInverse to prevent Jest-only matchers from bleeding into the Jasmine augmentation. |
| playgrounds/package-lock.json | Corrupted lock file: the node_modules/jest-diff entry now resolves to the jest-changed-files package URL/integrity, breaking npm ci in the playground. |
| types-checks-filter-out-node_modules.js | Suppresses TS2304 for unresolved Expected<T> type; silences a genuine consumer-visible gap rather than fixing the underlying type reference. |
| test/utils.test.ts | Adds comprehensive unit tests for new asymmetric-matcher utility functions using a mock Jasmine StringContaining class. |
| test-types/jasmine-global-expect-async/jasmine-expect-global.test-d.ts | Uncomments all previously-skipped type tests for the Jasmine global expect; adds coverage for withContext, promise matchers, and asymmetric matchers. |
| playgrounds/mocha/wdio.conf.ts | Adds four commented-out spec globs that appear to be leftover development artifacts. |
| playgrounds/jasmine/test/specs/expect-wdioImport/network-matchers.test.ts | New playground test for network matchers with Jasmine and expect asymmetric matchers; last it block has cosmetic 8-space indent instead of 4. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[asymmetric matcher passed to compareText / compareTextWithArray] --> B{isAsymmetricMatcher?}
B -- No --> C[string / RegExp path]
B -- Yes --> D{isStringContainingMatcherLike?}
D -- Yes, ignoreCase --> E{isWdioAsymmetricMatcher?}
E -- Yes: Wdio --> F[getAsymmetricMatcherValue → .sample]
E -- No: Jasmine --> G[getAsymmetricMatcherValue → .expected]
F --> H[isStrictlyStringContainingMatcher?]
G --> H
H -- Yes --> I[expect.stringContaining lower]
H -- No --> J[expect.not.stringContaining lower]
D -- No --> K[asymmetricMatch directly]
I --> K
J --> K
subgraph BUG in compareTextWithArray
L[item in expectedArray] --> M{isStringContainingMatcherLike?}
M -- Yes --> N[item.sample?.toString - undefined for Jasmine!]
end
Comments Outside Diff (5)
-
src/utils.ts, line 276-282 (link)compareTextWithArraystill uses.sampleinstead ofgetAsymmetricMatcherValuecompareTextwas updated to callgetAsymmetricMatcherValueto support both Wdio (sample) and Jasmine (expected) matchers underignoreCase. However, the parallelignoreCasebranch incompareTextWithArraywas NOT updated and still accessesitem.sample?.toString()directly. For any JasmineStringContainingmatcher passed in an array (which uses.expected, not.sample),item.sampleisundefined, soexpect.stringContaining(undefined)is called, producing silent incorrect results instead of a case-folded match. -
src/utils.ts, line 276-280 (link)Use
getAsymmetricMatcherValuehere, consistent withcompareText, to correctly extract the sample value from both Wdio (.sample) and Jasmine (.expected) matchers. The currentitem.sample?.toString()call returnsundefinedfor Jasmine matchers, causingexpect.stringContaining(undefined)to be created silently. -
playgrounds/package-lock.json, line 7988-8003 (link)node_modules/jest-diffentry resolves to the wrong packageThe
node_modules/jest-diffentry'sresolvedURL andintegritynow point tojest-changed-filesinstead ofjest-diff, and itsdependenciesarejest-changed-files's (execa,jest-util,p-limit) rather thanjest-diff's (@jest/diff-sequences,chalk,pretty-format). Runningnpm ciin the playgrounds directory will installjest-changed-filesunder thenode_modules/jest-diffpath, breakingjest-matcher-utilsand any other package that imports fromjest-diff. The lock file should be regenerated from a clean state. -
playgrounds/mocha/wdio.conf.ts, line 48-52 (link)Leftover development artifacts in
specsarrayFour commented-out spec globs (
basic-matchers.test.ts,soft-expect.test.ts,snapshot.test.ts,wdio-matchers.test.ts) were added alongside the existing wildcard. These look like temporary dev-time overrides used to run individual suites during development and should be removed before merging.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
-
playgrounds/jasmine/test/specs/expect-wdioImport/network-matchers.test.ts, line 513-521 (link)Misaligned indentation on the last
itblockThe final
it('should support wdio expect asymmetric matchers')is indented with 8 spaces instead of 4, unlike every otheritin the file. JavaScript ignores indentation so the test still runs correctly, but the inconsistency makes the code harder to read.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Reviews (1): Last reviewed commit: "Fix typing with `toBeResolvedTo` & `toBe..." | Re-trigger Greptile
| // Check if the line matches any exclusion pattern | ||
| const shouldExclude = excludeList.some(excludePath => | ||
| line.trim().startsWith(excludePath) |
There was a problem hiding this comment.
Silencing
Expected<T> type error hides a genuine resolution gap
Expected<T> is a @types/jasmine utility type used in jasmine-wdio-expect-async.d.ts to type toBeResolvedTo. Because @types/jasmine is excluded from tsconfig.types.json, the type is unresolved and the error is suppressed here. Consumers who add expect-webdriverio/jasmine-wdio-expect-async to their types without @types/jasmine will see the same TS2304 in their own project. Substituting the concrete type directly would keep the type check clean without a filter entry.
Fixes #1893
Fixes #1407 for real
Highlights:
jasmine-expect-global.test-dprovides proper Jasmine typing to useexpectasynchronously withwdio/jasmine-frameworkwithContextis support for sync & async matchersexpectAsyncwdio/jasmine-frameworkjasmine.stringContainingnow working with any text-based wdio matcherTODOs
Waiting
merge of: fix: Jasmine augmentationwithContextand add Playgrounds for Jasmine, Jest & Mocha #2010merge of fix: Global wait not working withtoBeDisplayed#2023