-
Notifications
You must be signed in to change notification settings - Fork 72
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
Improve type safety and code quality #383
Conversation
- Update test snapshots and test files in the `csf` and `playwright` directories. - Update `hooks.ts`, `index.ts`, `transformPlaywright.test.ts`, `transformPlaywright.ts`, `transformPlaywrightJson.test.ts`, `transformPlaywrightJson.ts`, `setup-page.ts`, `test-storybook.ts`, `getCliOptions.test.ts`, `getCliOptions.ts`, `getParsedCliOptions.test.ts`, `getStorybookMain.ts`, `getStorybookMetadata.ts`, `getTestRunnerConfig.test.ts`, `getTestRunnerConfig.ts`, and `tsconfig.json`. - These changes were made to improve the codebase and ensure compatibility with the latest dependencies and standards.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## enable-strict-mode #383 +/- ##
=====================================================
Coverage ? 92.05%
=====================================================
Files ? 15
Lines ? 277
Branches ? 72
=====================================================
Hits ? 255
Misses ? 22
Partials ? 0 ☔ View full report in Codecov by Sentry. |
…ansformCsf.ts, src/playwright/transformPlaywrightJson.ts, and src/typings.d.ts - Update package.json to include new dependencies or update existing ones. - Modify src/config/jest-playwright.ts to configure Jest with Playwright. - Refactor src/csf/transformCsf.ts to improve code readability and maintainability. - Update src/playwright/transformPlaywrightJson.ts to handle new Playwright JSON format. - Update src/typings.d.ts to include new type definitions or modify existing ones.
The __getContext variable was no longer being used in the codebase, so it was removed to improve code cleanliness and maintainability.
- Updated the `storyStoreV7` feature in the Storybook configuration to use a more concise expression. - Modified the test runner to handle cases where the element handler is null or undefined. - Added JSDoc type annotation for the exported Jest configuration.
- Refactored getStorybookMain.test.ts and getStorybookMain.ts files. - Made improvements to the utility functions for better performance and readability.
Simplified the logic in the `transformPlaywrightJson.ts` file to improve readability and maintainability. - Replaced the double negation with a single negation in the `makeTest` function. - Made the `tags` property optional in the `V4Entry` type. - Added a default value of `false` for the `metaOrStoryPlay` parameter in the `makeTest` function. - Removed the unused import of `TestRunnerConfig` in `test-storybook.ts`.
This commit includes changes to the transformPlaywrightJson module and its corresponding test file. The purpose of these changes is to refactor the code and improve its overall structure and readability.
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.
Thank you so much! Great stuff 🚀
🚀 PR was released in |
Description
This pull request introduces several changes to the codebase, primarily in the
src/csf
andsrc/playwright
directories. These changes aim to improve the code quality and functionality of the project.Changes in
src/config/jest-playwright.ts
import type { Config } from '@jest/types'
.TEST_RUNNER_PATH
now uses the nullish coalescing operator??
instead of||
.getJestPlaywrightConfig
explicitly declares return type asConfig.InitialOptions
.getJestConfig
function:Config.InitialOptions
.testMatch
.const config
with typeConfig.InitialOptions
.Changes in Snapshot Files
src/csf/__snapshots__/transformCsf.test.ts.snap
transformCsf
handling cases with no stories.Changes in
src/csf/transformCsf.test.ts
Modifications in
src/csf/transformCsf.ts
makePlayTest
andmakeDescribe
, return type altered tot.ExpressionStatement[]
.transformCsf
Record
type used instoryPlays
.playTests
to exclude null values.Changes in
src/playwright/hooks.ts
HttpHeaderSetter
to returnPromise<Record<string, string>>
.Adjustments in
src/playwright/index.ts
process
function signature streamlined by removingconfig
parameter.Updates in
src/playwright/transformPlaywright.test.ts
expect.addSnapshotSerializer
.Revisions in
src/playwright/transformPlaywright.ts
testPrefixer
with enhanced type safety and template literals usage.makeTitleFactory
uses template literals forfilePath
.Modifications in
src/playwright/transformPlaywrightJson.test.ts
transformPlaywrightJson
with type satisfactions.Changes in
src/playwright/transformPlaywrightJson.ts
transformPlaywrightJson
.Adjustments in
src/setup-page.ts
sanitizeURL
with template literals and improved logic.setupPage
with nullish coalescing.Changes in
src/test-storybook.ts
Modifications in TypeScript Definitions (
src/typings.d.ts
)Revisions in CLI Options Utilities (
src/util/getCliOptions.*
)Changes in
src/util/getStorybookMain.test.ts
storybookMainConfig
to the existing imports.getStorybookMain
returns theconfigDir
value fromstorybookMainConfig
if it exists.Changes in
src/util/getStorybookMain.ts
storybookMainConfig
Map is now exported.getStorybookMain
Function Changes:storybookMainConfig
for 'configDir' key instead ofconfigDir
argument.storybookMainConfig
to use 'configDir' as a constant key.Changes in
.storybook/main.ts
features
Configuration:storyStoreV7
:false
ifprocess.env.STORY_STORE_V7
equals 'false', otherwisetrue
.true
unlessprocess.env.STORY_STORE_V7
is explicitly 'false'.Changes in
.storybook/test-runner.ts
?.
) toinnerHTML
method call onelementHandler
.elementHandler
.Changes in
test-runner-jest.config.js
import('@jest/types').Config.InitialOptions
.These changes collectively enhance the codebase by improving type safety, code readability, and adherence to coding standards. The introduction of new tests and error handling ensures more robust functionality.
From: #323
📦 Published PR as canary version:
0.15.3--canary.383.049359f.0
✨ Test out this PR locally via:
Version
Published prerelease version:
v0.15.3-next.0
Changelog
🐛 Bug Fix
Authors: 2