Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 16 additions & 26 deletions .github/workflows/ci_framework-majors.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
name: '🔬 CI — Framework Majors'
name: "🔬 CI — Framework Majors"

on:
push:
branches:
- main
paths:
- '.github/workflows/ci_framework-majors.yml'
- 'src/**'
- 'tests/**'
- 'run.test.ts'
- 'package-lock.json'
- 'package.json'
- ".github/workflows/ci_framework-majors.yml"
- "src/**"
- "tests/**"
- "run.test.ts"
- "package-lock.json"
- "package.json"
pull_request:
paths:
- '.github/workflows/ci_framework-majors.yml'
- 'src/**'
- 'tests/**'
- 'run.test.ts'
- 'package-lock.json'
- 'package.json'
- ".github/workflows/ci_framework-majors.yml"
- "src/**"
- "tests/**"
- "run.test.ts"
- "package-lock.json"
- "package.json"
workflow_dispatch:

jobs:
Expand All @@ -28,7 +28,7 @@ jobs:
strategy:
fail-fast: false
matrix:
angular-major: ['18', '19', '20', '21']
angular-major: ["18", "19", "20", "21"]
name: Angular ${{ matrix.angular-major }}
steps:
- name: ➕ Actions - Checkout
Expand All @@ -37,7 +37,7 @@ jobs:
- name: ➕ Actions - Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
node-version: "22"

- name: ➕ Cache dependencies
uses: actions/cache@v4
Expand All @@ -49,15 +49,5 @@ jobs:
- name: 📦 Installing Dependencies
run: npm ci

- name: 🔁 Pin Angular ${{ matrix.angular-major }}
run: |
npm install --no-save \
@angular/common@${{ matrix.angular-major }} \
@angular/compiler@${{ matrix.angular-major }} \
@angular/core@${{ matrix.angular-major }} \
@angular/forms@${{ matrix.angular-major }} \
@angular/platform-browser@${{ matrix.angular-major }} \
@angular/platform-browser-dynamic@${{ matrix.angular-major }}

- name: 🔬 Angular ${{ matrix.angular-major }}
run: npm test
run: npm run test:major:${{ matrix.angular-major }}
62 changes: 29 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ npm i -D jsdom

```js
// poku.config.js
import { defineConfig } from 'poku';
import { angularTestingPlugin } from '@pokujs/angular/plugin';
import { defineConfig } from "poku";
import { angularTestingPlugin } from "@pokujs/angular/plugin";

export default defineConfig({
plugins: [
angularTestingPlugin({
dom: 'happy-dom',
dom: "happy-dom",
}),
],
});
Expand All @@ -85,26 +85,20 @@ export default defineConfig({

```ts
// tests/counter.test.ts
import { afterEach, assert, test } from 'poku';
import { cleanup, fireEvent, render, screen } from '@pokujs/angular';
import { CounterButton } from './CounterButton.ts';
import { afterEach, assert, test } from "poku";
import { cleanup, fireEvent, render, screen } from "@pokujs/angular";
import { CounterButton } from "./CounterButton.ts";

afterEach(cleanup);

await test('increments the counter', async () => {
await test("increments the counter", async () => {
await render(CounterButton, { inputs: { initialCount: 1 } });

assert.strictEqual(
screen.getByRole('heading').textContent,
'Count: 1'
);
assert.strictEqual(screen.getByRole("heading").textContent, "Count: 1");

await fireEvent.click(screen.getByRole('button', { name: 'Increment' }));
await fireEvent.click(screen.getByRole("button", { name: "Increment" }));

assert.strictEqual(
screen.getByRole('heading').textContent,
'Count: 2'
);
assert.strictEqual(screen.getByRole("heading").textContent, "Count: 2");
});
```

Expand All @@ -126,11 +120,11 @@ and this package verifies current support through Angular 21.

### Poku And DOM Support

| Package | Supported range |
| ------- | :-------------: |
| `poku` | `>=4.1.0` |
| `happy-dom` | `>=20` |
| `jsdom` | `>=22` |
| Package | Supported range |
| ----------- | :-------------: |
| `poku` | `>=4.1.0` |
| `happy-dom` | `>=20` |
| `jsdom` | `>=22` |

### Isolation Support

Expand Down Expand Up @@ -173,23 +167,23 @@ depends on NgModule-declared components, import the relevant module graph via
```ts
const view = await render(MyComponent, {
/** Signal inputs (input() / input.required()) */
inputs: { title: 'Hello' },
inputs: { title: "Hello" },
/** Additional providers for the test module */
providers: [{ provide: TOKEN, useValue: 'value' }],
providers: [{ provide: TOKEN, useValue: "value" }],
/** Additional imports (shared modules, pipes, directives) */
imports: [SharedModule],
/** Set false to skip the initial detectChanges() cycle */
detectChanges: true,
});

// Testing Library queries (scoped to document.body)
view.getByRole('heading');
view.getByRole("heading");

// Angular-specific helpers
await view.detectChanges(); // run a CD cycle
await view.rerender({ title: 'Hi' }); // update inputs
view.unmount(); // destroy fixture
view.fixture; // runtime fixture wrapper with componentRef/CD helpers
await view.detectChanges(); // run a CD cycle
await view.rerender({ title: "Hi" }); // update inputs
view.unmount(); // destroy fixture
view.fixture; // runtime fixture wrapper with componentRef/CD helpers
```

### `renderHook(fn, options?)`
Expand All @@ -201,8 +195,8 @@ promoting the new one, so `DestroyRef` cleanups and injector-bound effects do
not accumulate across renders.

```ts
const { result, rerender, unmount } = await renderHook(
() => inject(CounterService)
const { result, rerender, unmount } = await renderHook(() =>
inject(CounterService),
);

result.current.increment();
Expand Down Expand Up @@ -233,7 +227,7 @@ rejects with the application error.

```ts
await fireEvent.click(button);
await fireEvent.input(input, { target: { value: 'hello' } });
await fireEvent.input(input, { target: { value: "hello" } });
```

---
Expand All @@ -248,10 +242,10 @@ angularTestingPlugin({
* - 'jsdom' — broader browser API coverage
* - { setupModule } — path to a custom DOM setup module
*/
dom: 'happy-dom',
dom: "happy-dom",

/** Base URL assigned to the DOM environment. */
domUrl: 'http://localhost:3000/',
domUrl: "http://localhost:3000/",

/**
* Render metrics. Disabled by default.
Expand All @@ -273,3 +267,5 @@ angularTestingPlugin({
## License

[MIT](./LICENSE)

Render results also expose `componentInstance`, `asFragment()`, and `debug()`. Import `waitFor` from `@pokujs/angular` for assertion-aware polling.
Loading
Loading