Skip to content

RFC: nue.js domino based tests #499

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

Merged
merged 1 commit into from
Mar 11, 2025

Conversation

alexpricedev
Copy link
Contributor

Overview

This PR introduces a new testing infrastructure for Nue.js components using domino to simulate a browser environment. This allows us to run interactive component tests automatically in a lightweight and controlled DOM environment.

🙋‍♂️ It's a POC and I welcome comments on both the approach and structure of the test suite.

Goals

  1. Automated, interactive DOM tests
  2. Retain the ability to do manual browser testing, and ideally use the same components/files as the automated tests

New Test Suites

Added initial test suites for some basic & core features:

  1. Conditional Rendering (test-ifs/)
  2. Click Events (test-clicks/)
  3. Component References (test-refs/)

Running the tests

You can run the tests from the nuejs dir with bun test or if you run bun compile you can view them in the browser (assuming you're running a local server of some kind).

Nue.js Changes

I tried to keep changes to the core lib to a minimum for now, but I did have to replace new Text('') with document.createTextNode('') for better DOM compatibility.

Dependencies

Added:

"devDependencies": {
  "domino": "^2.1.6"
}

Next Steps

  • Add more test coverage for remaining and more complex features
  • Remove old manual browser test files
  • Add this testing into CI

@nobkd
Copy link
Collaborator

nobkd commented Mar 7, 2025

Here are some changes I made, (without really looking into the tests themselves, though. Will take a closer look, probably on Wednesday): alexpricedev#1

@tipiirai tipiirai merged commit db180b0 into nuejs:master Mar 11, 2025
4 of 6 checks passed
@tipiirai
Copy link
Contributor

Thanks @alexpricedev — stellar work. Lets discuss this week

@tipiirai
Copy link
Contributor

Perhaps domino should be a peerDependency? I think that makes sense, since most installs are for users and not Nue developers

@nobkd
Copy link
Collaborator

nobkd commented Mar 11, 2025

  • Peer dependencies are for users. They can be marked optional, so the users have to install them themselves. If they aren't marked optional, the users must already have installed them, or the package manager complains, I think.
  • Dev dependencies are for developers. They are not installed, when installing normally from npm, afaik
  • There are also optional dependencies, but they get automatically installed, if they are available for the platform.

So domino should stay a dev dependency, and esbuild and lcss are correct as both peer and dev.

It might be, that I got something wrong in my list above though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants