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

Fix Vue Tesing Library routes bug #12105

Merged
merged 4 commits into from
Apr 24, 2024

Conversation

AlexVelezLl
Copy link
Member

@AlexVelezLl AlexVelezLl commented Apr 23, 2024

Summary

For now there is a bug when we use the render function of Vue testing library without passing a routes prop, this has forced us to import VueRouter, and pass a routes: new VueRouter() prop just to avoid this error, although we don't use it. This means that we have more boilerplate code even for the simplest tests.

This error raises because for some reason vue router in its inner implementation checks if the $option.router object is defined, but just checking for undefined values, so when this value is null, it gives a null pointer exception.

Reviewer guidance

Check that VTL tests run successfully even if we dont pass the routes prop.

Testing checklist

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical user journeys are covered by Gherkin stories
  • Critical and brittle code paths are covered by unit tests

PR process

  • PR has the correct target branch and milestone
  • PR has 'needs review' or 'work-in-progress' label
  • If PR is ready for review, a reviewer has been added. (Don't use 'Assignees')
  • If this is an important user-facing change, PR or related issue has a 'changelog' label
  • If this includes an internal dependency change, a link to the diff is provided

Reviewer checklist

  • Automated test coverage is satisfactory
  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

@github-actions github-actions bot added DEV: frontend DEV: tools Internal tooling for development SIZE: small labels Apr 23, 2024
jest.conf.js Outdated
@@ -12,4 +12,6 @@ module.exports = Object.assign(baseConfig, {
'packages/hashi/src/*.js',
'packages/kolibri-tools/lib/src/*.js',
],
maxConcurrency: 2,
Copy link
Member

Choose a reason for hiding this comment

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

What is the reason for this? If the tests are having issues being parallelized, that tends to indicate there's an issue in the tests themselves (this only affects running on developer machines, as in a CI environment, Jest automatically runs tests sequentially instead).

Copy link
Member Author

Choose a reason for hiding this comment

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

Noooo I thought I deleted it, Im sorry. I changed it bc it was taking all my processors and my computer died trying to run the tests.

Copy link
Member

Choose a reason for hiding this comment

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

No worries - I did wonder if that was the case!

In future, you can also just pass additional jest CLI options: https://jestjs.io/docs/cli#--maxconcurrencynum for maxConcurrency and maxWorkers to the test invocation in Kolibri, it should pass through the additional arguments.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, for some reason I thought CLI options wasn't working but I think it was because I was passing maxConcurrency instead of maxWorkers. Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

Good to know, I had to do a bit of work to make sure our thin wrapper around jest passed through the additional CLI arguments, so I am glad that's still working!

Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

Looks good, and tests should be passing!

jest.conf.js Outdated
@@ -12,4 +12,6 @@ module.exports = Object.assign(baseConfig, {
'packages/hashi/src/*.js',
'packages/kolibri-tools/lib/src/*.js',
],
maxConcurrency: 2,
Copy link
Member

Choose a reason for hiding this comment

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

No worries - I did wonder if that was the case!

In future, you can also just pass additional jest CLI options: https://jestjs.io/docs/cli#--maxconcurrencynum for maxConcurrency and maxWorkers to the test invocation in Kolibri, it should pass through the additional arguments.

@rtibbles rtibbles merged commit 0de2806 into learningequality:develop Apr 24, 2024
31 checks passed
@AlexVelezLl AlexVelezLl deleted the fix-vtl-routing-bugs branch April 24, 2024 23:51
@AlexVelezLl
Copy link
Member Author

Thank you @rtibbles!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DEV: frontend DEV: tools Internal tooling for development SIZE: small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants