File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed
examples/pages-router/src/pages/amp
packages/tests-e2e/tests/pagesRouter Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * When doing `next build` you would get the error below:
3+ * TypeScript error: Property 'amp-timeago' does not exist on type 'JSX.IntrinsicElements'.
4+ * https://stackoverflow.com/questions/50585952/property-amp-img-does-not-exist-on-type-jsx-intrinsicelements/50601125#50601125
5+ * The workaround in that SO post doesn't work in this (mono)repo so I ended up using @ts-expect-error and @ts-ignore
6+ *
7+ */
8+
9+ export const config = { amp : true } ;
10+
11+ export async function getServerSideProps ( ) {
12+ return {
13+ props : {
14+ time : new Date ( ) . toISOString ( ) ,
15+ } ,
16+ } ;
17+ }
18+
19+ function MyAmpPage ( { time } : { time : string } ) {
20+ const date = new Date ( time ) ;
21+
22+ return (
23+ < div >
24+ < p > Some time: { date . toJSON ( ) } </ p >
25+ { /* @ts -expect-error AMP Component not recognized by TypeScript */ }
26+ < amp-timeago
27+ width = "0"
28+ height = "15"
29+ datetime = { date . toJSON ( ) }
30+ layout = "responsive"
31+ data-testid = "amp-timeago"
32+ >
33+ .{ /* @ts -ignore */ }
34+ </ amp-timeago >
35+ </ div >
36+ ) ;
37+ }
38+
39+ export default MyAmpPage ;
Original file line number Diff line number Diff line change 1+ import { expect , test } from "@playwright/test" ;
2+
3+ test . describe ( "next/amp" , ( ) => {
4+ test ( "should load and display the timeago component" , async ( { page } ) => {
5+ await page . goto ( "/amp" ) ;
6+ const timeago = await page . getByTestId ( "amp-timeago" ) . textContent ( ) ;
7+ expect ( timeago ) . toBe ( "just now" ) ;
8+ } ) ;
9+ } ) ;
You can’t perform that action at this time.
0 commit comments