Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: mock image path as next/image expects it #34350

Merged
merged 14 commits into from Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/next/build/jest/__mocks__/fileMock.js
@@ -1 +1 @@
module.exports = 'test-file-stub'
module.exports = '/test-file-stub'
11 changes: 11 additions & 0 deletions test/production/next/jest/index.test.ts
Expand Up @@ -8,13 +8,23 @@ describe('next/jest', () => {
beforeAll(async () => {
next = await createNext({
files: {
'public/vercel.svg':
'<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg"/>',
'components/image.js': `
import Image from "next/image"
import img from "../public/vercel.svg"
export function Img() {
return <Image src={img} alt="logo" width={24} height={24} />
balazsorban44 marked this conversation as resolved.
Show resolved Hide resolved
}
`,
'components/comp.js': `
export default function Comp() {
return <h1>Hello Dynamic</h1>;
}
`,
'pages/index.js': `
import dynamic from "next/dynamic";
import { Img } from "../components/image";

const Comp = dynamic(() => import("../components/comp"), {
loading: () => <h1>Loading...</h1>,
Expand All @@ -23,6 +33,7 @@ describe('next/jest', () => {
export default function Page() {
return <>
<Comp />
<Img/>
<p>hello world</p>
</>
}
Expand Down