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

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

Merged
merged 18 commits into from
Jul 4, 2024

Conversation

ataromoku
Copy link
Contributor

@ataromoku ataromoku 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.

@ataromoku ataromoku changed the title Bump react-valence-ui-iframe Migrate to Jest and Webpack to be more compatible with Lit 3 Jun 21, 2024
@ataromoku ataromoku requested review from a team, prajapac and br-cz and removed request for a team June 21, 2024 11:33
@ataromoku ataromoku marked this pull request as ready for review 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!

@@ -3,7 +3,8 @@
"parserOptions": {
"ecmaFeatures": {
"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

@@ -1,7 +1,7 @@
'use strict';

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 👍

@@ -41,6 +41,7 @@ describe('Generic Viewer', function() {

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 💯

@@ -18,7 +18,7 @@ describe('Image Plugin', function() {
});

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

@@ -10,7 +10,7 @@ describe('Generic Plugin', function() {
});

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

@ataromoku ataromoku requested a review from prajapac July 3, 2024 16:31
@ataromoku ataromoku 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
@ataromoku ataromoku merged commit 0c6d037 into master Jul 4, 2024
1 check passed
ataromoku 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
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