Skip to content

Commit

Permalink
test: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprobst committed Jul 28, 2021
1 parent d15b514 commit f43ab22
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/integration/eslint/config-core-web-vitals/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "next/core-web-vitals",
"root": true
}
9 changes: 9 additions & 0 deletions test/integration/eslint/config-core-web-vitals/pages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const Home = () => (
<div>
<p>Home</p>
<script src="https://example.com" />
<img src="https://example.com/image.png" />
</div>
)

export default Home
16 changes: 16 additions & 0 deletions test/integration/eslint/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jest.setTimeout(1000 * 60 * 2)

const dirFirstTimeSetup = join(__dirname, '../first-time-setup')
const dirCustomConfig = join(__dirname, '../custom-config')
const dirWebVitalsConfig = join(__dirname, '../config-core-web-vitals')
const dirPluginRecommendedConfig = join(
__dirname,
'../plugin-recommended-config'
Expand Down Expand Up @@ -167,6 +168,21 @@ describe('ESLint', () => {
)
})

test('shows warnings and errors with next/core-web-vitals config', async () => {
const { stdout, stderr } = await nextLint(dirWebVitalsConfig, [], {
stdout: true,
stderr: true,
})

const output = stdout + stderr
expect(output).toContain(
"Warning: Do not use <img>. Use Image from 'next/image' instead."
)
expect(output).toContain(
'Error: External synchronous scripts are forbidden'
)
})

test('shows warnings and errors when extending plugin recommended config', async () => {
const { stdout, stderr } = await nextLint(
dirPluginRecommendedConfig,
Expand Down

0 comments on commit f43ab22

Please sign in to comment.