Unverified Commit 1f93d497 authored by Janka Uryga's avatar Janka Uryga Committed by GitHub

test: try to fix flakiness in amphtml util (#78304)

This PR modifies the AMP HTML testing util to avoid loading the
validator from the network, which causes random test flakiness. I've
also made it use the validator from `next/dist/compiled` to match what
we do during builds. This means we can drop `amphtml-validator` from the
root package.json.
parent 37545d59
...@@ -144,7 +144,6 @@ ...@@ -144,7 +144,6 @@
"@vercel/og": "0.6.8", "@vercel/og": "0.6.8",
"abort-controller": "3.0.0", "abort-controller": "3.0.0",
"alex": "9.1.0", "alex": "9.1.0",
"amphtml-validator": "1.0.38",
"async-sema": "3.0.1", "async-sema": "3.0.1",
"babel-plugin-react-compiler": "19.0.0-beta-e552027-20250112", "babel-plugin-react-compiler": "19.0.0-beta-e552027-20250112",
"browserslist": "4.22.2", "browserslist": "4.22.2",
......
...@@ -219,9 +219,6 @@ importers: ...@@ -219,9 +219,6 @@ importers:
alex: alex:
specifier: 9.1.0 specifier: 9.1.0
version: 9.1.0 version: 9.1.0
amphtml-validator:
specifier: 1.0.38
version: 1.0.38
async-sema: async-sema:
specifier: 3.0.1 specifier: 3.0.1
version: 3.0.1 version: 3.0.1
/* eslint-env jest */ /* eslint-env jest */
import amphtmlValidator from 'amphtml-validator' import amphtmlValidator from 'next/dist/compiled/amphtml-validator'
export async function validateAMP(html) { // Use the same validator that we use for builds.
const validator = await amphtmlValidator.getInstance() // This avoids trying to load one from the network, which can cause random test flakiness.
// (duplicated from 'packages/next/src/export/routes/pages.ts')
const validatorPath = require.resolve(
'next/dist/compiled/amphtml-validator/validator_wasm.js'
)
export async function validateAMP(/** @type {string} */ html) {
const validator = await amphtmlValidator.getInstance(validatorPath)
const result = validator.validateString(html) const result = validator.validateString(html)
if (result.status !== 'PASS') { if (result.status !== 'PASS') {
for (let ii = 0; ii < result.errors.length; ii++) { for (let ii = 0; ii < result.errors.length; ii++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment