Skip to content

Draft: Playground unit-test-utils module #836

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

Closed
wants to merge 1 commit into from

Conversation

adamziel
Copy link
Collaborator

@adamziel adamziel commented Dec 2, 2023

To use real WordPress in unit tests, we need to import it from somewhere. At the moment, there is no easy way to do it without running into a circular dependency problem. This PR adds a new module that has no explicit import dependencies to solve that problem. It still does have an implicit path-based dependency on the remote package, which isn't ideal.

Perhaps a better solution would be to build WordPress .data artifacts to yet another dependency-free module such as @wp-playground/wordpress, and then all other package would import from that module without introducing a circular dependency.

Related to #463

I generated this module as follows:

nx generate @nx/js:library --name=unit-test-utils --unitTestRunner=vitest --bundler=vite --directory=packages/playground --importPath=@wp-playground/unit-test-utils --no-interactive

cc @reimic

To use real WordPress in unit tests, we need to import it from
somewhere. At the moment, there is no easy way to do it without running
into a circular dependency problem. This PR adds a new module that has
no explicit import dependencies to solve that problem. It still does
have an implicit path-based dependency on the remote package, which
isn't ideal. Perhaps the build WordPress files could be moved to
yet another dependency-free module such as wp-playground/wordpress and
the remote package would use those files in its build process.
@adamziel
Copy link
Collaborator Author

adamziel commented Dec 3, 2023

The only value added by unit-test-utils at the moment would be access to WordPress data modules. I think a module like @wp-playground/wordpress would be better suited to that task – let's close this PR and continue these explorations in #837.

@adamziel adamziel closed this Dec 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant