rsnext/test/e2e/next-image-forward-ref/index.test.ts
Jan Kaifer c4b6bb8521
Add ref forwarding for next/image (#43193)
Add ref forwarding for next/image with integration test


- fixes https://github.com/vercel/next.js/discussions/42885
- fixes https://github.com/vercel/next.js/issues/18398 (this one was closed with `onLoadingComplete`)

## Feature

- [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Documentation added


Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2022-11-25 15:08:50 +00:00

33 lines
935 B
TypeScript

import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { waitFor } from 'next-test-utils'
import path from 'path'
import webdriver from 'next-webdriver'
describe('next-image-forward-ref', () => {
let next: NextInstance
const appDir = path.join(__dirname, 'app')
beforeAll(async () => {
next = await createNext({
files: new FileRef(appDir),
dependencies: {
'framer-motion': '7.6.9',
},
})
})
afterAll(() => next.destroy())
it('allows framer-motion to animate opacity', async () => {
const browser = await webdriver(next.url, '/framer-motion')
expect(
Number(await browser.elementById('img').getComputedCss('opacity'))
).toBeCloseTo(1)
browser.elementById('img').click()
await waitFor(1000)
expect(
Number(await browser.elementById('img').getComputedCss('opacity'))
).toBeCloseTo(0)
})
})