Add test infrastructure with bun and jsdom#60
Conversation
Co-authored-by: L3P3 <4629449+L3P3@users.noreply.github.com>
Co-authored-by: L3P3 <4629449+L3P3@users.noreply.github.com>
Co-authored-by: L3P3 <4629449+L3P3@users.noreply.github.com>
L3P3
left a comment
There was a problem hiding this comment.
- add closure-compiler to dev dependencies too
- use "latest" for dev dependencies
- now that we have bun, use bun for building too, also in the build action
- the "setup dom" step in every test file is redundant, please move that to a single file imported by the others
…or build, extract setup Co-authored-by: L3P3 <4629449+L3P3@users.noreply.github.com>
All four points addressed in commit daa6efd:
|
L3P3
left a comment
There was a problem hiding this comment.
Instead of await import lui, do it at the top of the file and format it like this:
import './setup.js';
import {
expect,
test,
} from 'bun:test';
import {
init,
node_dom,
} from '../src/lui.js';
test(...setup.js should not return a setupDOM function but just do it once imported.
Most tests should use document.body as root and in case they use it as root, the init call's second argument should be omitted as its body by default.
Several tests have a timeout after the init call which is pointless as lui renders dom updates synchronously. Remove them where not needed.
…roots Co-authored-by: L3P3 <4629449+L3P3@users.noreply.github.com>
All changes addressed in commit 0f443eb:
Tests use unique root elements because bun runs all tests in the same process, so the lui module is cached with its captured |
|
@copilot True, we cannot recreate the dom for every test. So instead, let setup.js export a root_create function so that each test has a |
Co-authored-by: L3P3 <4629449+L3P3@users.noreply.github.com>
Done in commit e27d4e4. The |
|
@copilot The tests are executed on every push here because in github actions, we listen for push and pull requests. |
Better Testing Implementation - Complete ✅
testdirectory toexamplestestdirectory with minimal test filesSummary
This PR successfully implements a proper testing infrastructure for the lui repository using bun test and jsdom. The original test directory has been renamed to
examplesto better reflect its purpose, and a newtestdirectory contains minimal test files that validate core lui functionality.Recent Updates (addressing feedback):
google-closure-compilerto dev dependencieslatestversionbuninstead ofnodetest/setup.jsthat runs automatically on importasync/awaitfrom tests (not needed since lui renders synchronously)root_create()export from setup.js for creating unique test rootsconst root = root_create();at the startTest Coverage:
app-root.test.js)app-template.test.js)app-list.test.js)hook-state.test.js)hook-model.test.js)hook-assert.test.js)All tests pass successfully (6/6) and are ready to run in CI.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.