-
Notifications
You must be signed in to change notification settings - Fork 19
[WTF-2485]: Remove enzyme from widget generator in preparation of React 19 #156
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
base: master
Are you sure you want to change the base?
Changes from all commits
4a81c3e
66fbe7d
e413267
5c6c594
77dcc7b
fb1d082
c39ff24
6ef55e0
b23c9e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,8 +21,8 @@ | |
| "build": "pluggable-widgets-tools build:web", | ||
| "lint": "pluggable-widgets-tools lint", | ||
| "lint:fix": "pluggable-widgets-tools lint:fix", | ||
| "test": "pluggable-widgets-tools test:unit:web --no-cache --ci && npm run test:e2e", | ||
| "test:unit": "pluggable-widgets-tools test:unit:web --coverage", | ||
| "test": "pluggable-widgets-tools test:unit:web && npm run test:e2e", | ||
| "test:unit": "pluggable-widgets-tools test:unit:web", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When running unit tests on a generated widget from the command line I get the following error:
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was the widget using the correct packages? The testing procedure I used resulted in the tests passing without errors: # Prepare artifacts
cd $PATH_TO_REPO
pnpm install
pnpm --dir packages/pluggable-widgets-tools pack
cd ~/Mendix/TestApp/myPluggableWidgets
$PATH_TO_REPO/packages/generator-widget/bin.js fullBPWidget
# Choose full boilerplate and say yes to tests
cd fullPBWidget
npm install $PATH_TO_REPO/packages/pluggable-widgets-tools/mendix-pluggable-widgets-tools-11.3.0.tgz
npm test
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @weirdwater I did not use the pluggable widget tools from this branch. The tools version mentioned in the package json on a fresh generated widget mentioned ^10.15.0 so I was expecting it to work with that version.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would explain the discrepancy between the different testing experiences. As you say, if the updated tools are needed, we should update the minimum version in the generator. In this case the changes in both packages cannot be seen separate from each other. So the minimum version in the package template should be updated to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The dependency version should indeed be raised, as this is also a breaking change anyways. But still, this is a concern for after the package is published. The error I'm getting (which is different than the one Marco shared) after making sure the widget targets |
||
| "test:e2e": "npx cypress open --browser chrome --e2e", | ||
| "prerelease": "npm run lint", | ||
| "release": "pluggable-widgets-tools release:web" | ||
|
|
@@ -36,10 +36,12 @@ | |
| }, | ||
| "resolutions": { | ||
| "react": "^18.2.0", | ||
| "react-dom": "18.2.0", | ||
| "react-native": "0.72.7" | ||
| }, | ||
| "overrides": { | ||
| "react": "^18.2.0", | ||
| "react-dom": "18.2.0", | ||
| "react-native": "0.72.7" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,19 @@ | ||
| import { createElement } from "react"; | ||
| import { shallow } from "enzyme"; | ||
| import { render } from "@testing-library/react"; | ||
| import "@testing-library/jest-dom"; | ||
|
|
||
| import { HelloWorldSample } from "../HelloWorldSample"; | ||
|
|
||
| describe("HelloWorldSample", () => { | ||
| const createHelloWorld = (props) => shallow(<HelloWorldSample {...props} />); | ||
|
|
||
| it("should render the structure correctly", () => { | ||
| const helloWorldProps = { | ||
| sampleText: "World" | ||
| }; | ||
| const helloWorld = createHelloWorld(helloWorldProps); | ||
|
|
||
| expect( | ||
| helloWorld.equals( | ||
| <div className="widget-hello-world">Hello {helloWorldProps.sampleText}</div> | ||
| ) | ||
| ).toEqual(true); | ||
| const { container } = render(<HelloWorldSample {...helloWorldProps} />); | ||
|
|
||
| const helloWorld = container.querySelector(".widget-hello-world"); | ||
| expect(helloWorld).toBeInTheDocument(); | ||
| expect(helloWorld).toHaveTextContent(`Hello ${helloWorldProps.sampleText}`); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,19 @@ | ||
| import { createElement } from "react"; | ||
| import { shallow } from "enzyme"; | ||
| import { render } from "@testing-library/react"; | ||
| import "@testing-library/jest-dom"; | ||
|
|
||
| import { HelloWorldSample } from "../HelloWorldSample"; | ||
|
|
||
| describe("HelloWorldSample", () => { | ||
| const createHelloWorld = (props) => shallow(<HelloWorldSample {...props} />); | ||
|
|
||
| it("should render the structure correctly", () => { | ||
| const helloWorldProps = { | ||
| sampleText: "World" | ||
| }; | ||
| const helloWorld = createHelloWorld(helloWorldProps); | ||
|
|
||
| expect( | ||
| helloWorld.equals( | ||
| <div className="widget-hello-world">Hello {helloWorldProps.sampleText}</div> | ||
| ) | ||
| ).toEqual(true); | ||
| const { container } = render(<HelloWorldSample {...helloWorldProps} />); | ||
|
|
||
| const helloWorld = container.querySelector(".widget-hello-world"); | ||
| expect(helloWorld).toBeInTheDocument(); | ||
| expect(helloWorld).toHaveTextContent(`Hello ${helloWorldProps.sampleText}`); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,19 @@ | ||
| import { createElement } from "react"; | ||
| import { shallow, ShallowWrapper } from "enzyme"; | ||
| import { render } from "@testing-library/react"; | ||
| import "@testing-library/jest-dom"; | ||
|
|
||
| import { HelloWorldSample, HelloWorldSampleProps } from "../HelloWorldSample"; | ||
|
|
||
| describe("HelloWorldSample", () => { | ||
| const createHelloWorld = (props: HelloWorldSampleProps): ShallowWrapper => shallow(<HelloWorldSample {...props} />); | ||
|
|
||
| it("should render the structure correctly", () => { | ||
| const helloWorldProps: HelloWorldSampleProps = { | ||
| sampleText: "World" | ||
| }; | ||
|
|
||
| const helloWorld = createHelloWorld(helloWorldProps); | ||
| const { container } = render(<HelloWorldSample {...helloWorldProps} />); | ||
|
|
||
| expect( | ||
| helloWorld.equals( | ||
| <div className="widget-hello-world">Hello {helloWorldProps.sampleText}</div> | ||
| ) | ||
| ).toEqual(true); | ||
| const helloWorld = container.querySelector(".widget-hello-world"); | ||
| expect(helloWorld).toBeInTheDocument(); | ||
| expect(helloWorld).toHaveTextContent(`Hello ${helloWorldProps.sampleText}`); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,19 @@ | ||
| import { createElement } from "react"; | ||
| import { shallow, ShallowWrapper } from "enzyme"; | ||
| import { render } from "@testing-library/react"; | ||
| import "@testing-library/jest-dom"; | ||
|
|
||
| import { HelloWorldSample, HelloWorldSampleProps } from "../HelloWorldSample"; | ||
|
|
||
| describe("HelloWorldSample", () => { | ||
| const createHelloWorld = (props: HelloWorldSampleProps): ShallowWrapper => shallow(<HelloWorldSample {...props} />); | ||
|
|
||
| it("should render the structure correctly", () => { | ||
| const helloWorldProps: HelloWorldSampleProps = { | ||
| sampleText: "World" | ||
| }; | ||
|
|
||
| const helloWorld = createHelloWorld(helloWorldProps); | ||
| const { container } = render(<HelloWorldSample {...helloWorldProps} />); | ||
|
|
||
| expect( | ||
| helloWorld.equals( | ||
| <div className="widget-hello-world">Hello {helloWorldProps.sampleText}</div> | ||
| ) | ||
| ).toEqual(true); | ||
| const helloWorld = container.querySelector(".widget-hello-world"); | ||
| expect(helloWorld).toBeInTheDocument(); | ||
| expect(helloWorld).toHaveTextContent(`Hello ${helloWorldProps.sampleText}`); | ||
| }); | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.