ampproject / ampproject/worker-dom

Testing: Verify mutation triggers in worker-thread

Open
#157 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3.3k
Forks
154
PR merge metrics
No merged PRs in 30d

Description

**Suggestion**: Element tests in src/test/ should verify that `mutator.ts` is invoked with the correct params. Refactoring `mutator.ts` from module-level vars into a class would help mockability in unit tests.

For example:
```js
test('HTMLInputElement.value', t => {
const {element, mutator} = t.context;
element.value = 123;
expect(mutator.mutate).calledWithMatch({type: PROPERTIES, value: 123});
});
```

Contributor guide

Open the contributing guide

Research direction

Start by reading src/test/ and mutator.ts, then trace how an element mutation reaches the worker-thread mutator. Use the HTMLInputElement.value example as the first test case and verify that mutate receives the expected type and value parameters. Done means the relevant element tests cover these calls and the mutator is mockable as described.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.