ampproject / ampproject/amphtml

amp-story: unit tests fail when "reduce-motion" setting is enabled.

Open
#35,969 5 comments 0 reactions 0 assignees View on GitHub
Stale Type: Bug WG: stories
Dominant language
JavaScript
Stars
14.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

### Description

`npx amp unit --files=extensions/amp-story/1.0/amp-story.js` fails when reduce motion is enabled. I believe this is because it is the only codepath that utilizes the Performance service which needs to be stubbed.

Error:
```
ERROR: '_service.Services.performanceFor(...).addEnabledExperiment is not a function [object HTMLElement]'
```

Source:
https://github.com/ampproject/amphtml/blob/e16bbdaa94c2148ab8126238c26023ff5767675e/extensions/amp-story/1.0/amp-story.js#L456-L463

### Reproduction Steps

1. Enable "Reduced motion" in accessibility settings of your OS
2. Run any amp story unit tests

cc @ampproject/wg-stories

Contributor guide

Open the contributing guide

Research direction

Start with extensions/amp-story/1.0/amp-story.js at the referenced lines and run `npx amp unit --files=extensions/amp-story/1.0/amp-story.js` with reduced motion enabled. Trace the Performance service use and its test setup; done means the AMP story unit tests pass without the addEnabledExperiment error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.