-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(nextjs): Add spec files when creating a next app (#22079)
- Loading branch information
1 parent
c284d3d
commit 285a543
Showing
6 changed files
with
23 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 9 additions & 4 deletions
13
packages/next/src/generators/application/files/common/specs/__fileName__.spec.tsx__tmpl__
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
<% if (src) { %> | ||
<% if (src && !appDir) { %> | ||
import Index from '../src/pages/index'; | ||
<% } else { %> | ||
<% } else if (!appDir) { %> | ||
import Index from '../pages/index'; | ||
<% } else if (appDir && src) {%> | ||
import Page from '../src/app/page'; | ||
<% } else { %> | ||
import Page from '../app/page'; | ||
<% } %> | ||
describe('Index', () => { | ||
|
||
describe(<%- appDir ? `'Page'` : `'Index'` %>, () => { | ||
it('should render successfully', () => { | ||
const { baseElement } = render(<Index />); | ||
const { baseElement } = render(<%- appDir ? `<Page />` : `<Index />` %>); | ||
expect(baseElement).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters