Skip to content
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(tests): pro 168 refactor tests #842

Merged
merged 42 commits into from
Aug 23, 2024
Merged

Conversation

alvarosabu
Copy link
Contributor

@alvarosabu alvarosabu commented Jul 23, 2024

Pull request type

Jira Link: INT-

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Other (please describe):

How to test this PR

Unit tests

pnpm run test

E2E

pnpm run test:e2e

Copy link

Refactor tests

@alvarosabu alvarosabu marked this pull request as ready for review August 22, 2024 12:43
@@ -0,0 +1,147 @@
import StoryblokClient from '../src/'
Copy link
Contributor

Choose a reason for hiding this comment

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

@alvarosabu while in the unit tests is perfectly fine, as this is an integration test (api tests to be more specific) it shouldn't use the src, but rather the compiled version of the client

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Thanks

vitest.config.e2e.ts Outdated Show resolved Hide resolved
vitest.config.ts Outdated
export default defineConfig({
test: {
include: ['./tests/**/*.test.ts'],
exclude: ['./old-tests'],
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

Also, more as an opinion, how would you see to separate the tests in tests/unit and test/api (or test/e2e) folders? I feel it can be more clearly organized like that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @alexjoverm, good point, what about having the unit tests in the same place as the code and API tests on the e2e folder? Seems to be a common practice between test advocates

--- index.ts
--- index.test.ts

Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't be against - to me I also prefer that practice as it's more modular, and at the end, a unit test it's tightly couple to the "component" that is testing.

Only thing is that we'd be introducing an inconsistency with the other packages as they have it in a test folder - but we can pioneer the new approach from js-client, and later in time apply it to other pkgs when we update tests there. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree. Mmm, since we already introduced the pnpm workspaces setup, I think it's worth start propagating these new practices down.

@alvarosabu alvarosabu merged commit c8a3a45 into main Aug 23, 2024
2 of 3 checks passed
Copy link

🎉 This PR is included in version 6.8.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Comment on lines -18 to +20

strategy:
matrix:
node-version: [20]
Copy link
Contributor

@ryami333 ryami333 Aug 23, 2024

Choose a reason for hiding this comment

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

The matrix strategy for such a workflow is redundant - you wouldn't (and can't) publish a package with multiple Node versions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @ryami333 how would you suggest to setup the CI instead? Could you create a PR with your approach to discuss it?

We normally keep node versions to the latest LTS, do you see it beneficial to aim for multiple node versions?

Thanks!

Copy link
Contributor

@ryami333 ryami333 Aug 23, 2024

Choose a reason for hiding this comment

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

The purpose of matrix strategies is "Running variations of jobs in a workflow". Configuring this job with a matrix strategy is redundant for two reasons:

  • You've only put one element (20) in the matrix, so it's effectively the same as running it without a matrix strategy at all. You could have just written the Node version directly in the actions/setup-node step, as it was before this PR.
  • You wouldn't want to add any other versions to this particular workflow's matrix, because you wouldn't be able be publish the package two-or-more times. For "testing" / "linting" workflows it makes sense to run the workflow with multiple Node versions (eg. [18, 20, …etc]) - once for each Node version that the library officially supports. But again - you can't publish a library multiple times.

Copy link
Contributor Author

@alvarosabu alvarosabu Aug 23, 2024

Choose a reason for hiding this comment

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

Hi @ryami333 that makes sense, thanks for the clear explanation.

I just created a PR tackling this, lets continue the conversation there #851

@alvarosabu alvarosabu mentioned this pull request Aug 23, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants