Skip to content

BREAKING CHANGE: Migrate to Jest and Webpack to be more compatible with Lit 3 #118

Merged
wladco merged 18 commits intomasterfrom
bump-react-valence-ui-iframe
Jul 4, 2024
Merged

BREAKING CHANGE: Migrate to Jest and Webpack to be more compatible with Lit 3 #118
wladco merged 18 commits intomasterfrom
bump-react-valence-ui-iframe

Conversation

@wladco
Copy link
Contributor

@wladco wladco commented Jun 12, 2024

Related jira:

https://desire2learn.atlassian.net/browse/PHNX-1954

This PR:

  • Replaces Karma, Browserify, Babelify with Jest, Webpack.
  • Bumps bump-react-valence-ui-iframe.
  • Only affects the tests and demo, it doesn't modify the logic itself.

Why do we need this?

While configuring the Babelify for Lit 3, we had to update some dependencies that bring along others. As a result, we arrive at a configuration where we can no longer stably work with React versions earlier than 16.

Why Jest?

Jest is perfectly compatible with React. It debugs well and doesn't require a bundler to execute tests.

@wladco wladco changed the title Bump react-valence-ui-iframe Migrate to Jest and Webpack to be more compatible with Lit 3 Jun 21, 2024
@wladco wladco requested review from a team, br-cz and prajapac and removed request for a team June 21, 2024 11:33
@wladco wladco marked this pull request as ready for review June 21, 2024 11:34
@wladco wladco requested a review from jstefaniuk-d2l as a code owner June 21, 2024 11:34
Copy link

@brissons brissons left a comment

Choose a reason for hiding this comment

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

a couple of nits but otherwise lgtm!

"jsx": true
}
},
"ecmaVersion": 2018
Copy link

Choose a reason for hiding this comment

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

would we want the latest version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, the last version this code works with is the 2018


var React = require('react'), //eslint-disable-line no-unused-vars
TestUtils = require( 'react-addons-test-utils' ),
var React = require('react'), //eslint-disable-line no-unused-
Copy link

Choose a reason for hiding this comment

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

nit: is //eslint-disable-line no-unused- still required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed 👍


it('should render wrapper with expected class name', function() {
var elem = TestUtils.renderIntoDocument(

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Is this newline intentionally added?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unintentionally 💯


it('should return a view', function() {
var viewer = ImagePlugin.getComponent();
var viewer = ImagePlugin.getComponent({src: 'test'});
Copy link
Contributor

Choose a reason for hiding this comment

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

For the test in src/plugins/html/__tests__/htmlPluginTests.js, the file ends in .html, i.e. src: 'test.html', should this have the extension too, or perhaps the other test shouldn't have it? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thx, any value will do here, so I removed the .html for consistency

jest.config.js Outdated
Comment on lines +2 to +7
// ORIGINAL COMMENT FROM REMOVED KARMA CONFIG:
// There's a pre-test stall on Travis builds that can cause Karma to
// fail with the default timeout of 10s. I'm not sure what's causing
// the stall, but this mitigates it for now.
//
// KEEPING THE TIMEOUT JUST IN CASE
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't use Travis for builds anymore (should be GitHub Actions), so I wonder if the comment/timeout is still relevant 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed


it('should return a view', function() {
var viewer = GenericPlugin.getComponent();
var viewer = GenericPlugin.getComponent({src: 'test'});
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as for src/plugins/image/__tests__/imagePluginTests.js file

Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, what led to this var name change from native to plugin?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's weird, but test fails with ReferenceError: native is not defined if we name this variable differently from exported here

@wladco wladco requested a review from prajapac July 3, 2024 16:31
@wladco wladco changed the title Migrate to Jest and Webpack to be more compatible with Lit 3 BREAKING CHANGE: Migrate to Jest and Webpack to be more compatible with Lit 3 Jul 4, 2024
@wladco wladco merged commit 0c6d037 into master Jul 4, 2024
wladco added a commit that referenced this pull request Jul 4, 2024
…th Lit 3 (#118)

BREAKING CHANGE:
Migrate to Jest and Webpack to be more compatible with Lit 3
@d2l-github-release-tokens
Copy link

🎉 This PR is included in version 3.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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