forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add hello-world test for pages and app (vercel#50780)
## What? Recently I've been using these hello-world tests quite often to get the baseline traces out for `pages` and `app`. Adding them to the repo so that I don't have to recreate / stash them all the time.
- Loading branch information
1 parent
627b9b2
commit 8101758
Showing
6 changed files
with
87 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function Root({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<html> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Page() { | ||
return <p>hello world</p> | ||
} |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { createNextDescribe } from 'e2e-utils' | ||
|
||
createNextDescribe( | ||
'hello-world', | ||
{ | ||
files: __dirname, | ||
}, | ||
({ next }) => { | ||
// Recommended for tests that check HTML. Cheerio is a HTML parser that has a jQuery like API. | ||
it('should work using cheerio', async () => { | ||
const $ = await next.render$('/') | ||
expect($('p').text()).toBe('hello world') | ||
}) | ||
|
||
// Recommended for tests that need a full browser | ||
it('should work using browser', async () => { | ||
const browser = await next.browser('/') | ||
expect(await browser.elementByCss('p').text()).toBe('hello world') | ||
}) | ||
|
||
// In case you need the full HTML. Can also use $.html() with cheerio. | ||
it('should work with html', async () => { | ||
const html = await next.render('/') | ||
expect(html).toContain('hello world') | ||
}) | ||
|
||
// In case you need to test the response object | ||
it('should work with fetch', async () => { | ||
const res = await next.fetch('/') | ||
const html = await res.text() | ||
expect(html).toContain('hello world') | ||
}) | ||
} | ||
) |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* @type {import('next').NextConfig} | ||
*/ | ||
const nextConfig = {} | ||
|
||
module.exports = nextConfig |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { createNextDescribe } from 'e2e-utils' | ||
|
||
createNextDescribe( | ||
'hello-world', | ||
{ | ||
files: __dirname, | ||
}, | ||
({ next }) => { | ||
// Recommended for tests that check HTML. Cheerio is a HTML parser that has a jQuery like API. | ||
it('should work using cheerio', async () => { | ||
const $ = await next.render$('/') | ||
expect($('p').text()).toBe('hello world') | ||
}) | ||
|
||
// Recommended for tests that need a full browser | ||
it('should work using browser', async () => { | ||
const browser = await next.browser('/') | ||
expect(await browser.elementByCss('p').text()).toBe('hello world') | ||
}) | ||
|
||
// In case you need the full HTML. Can also use $.html() with cheerio. | ||
it('should work with html', async () => { | ||
const html = await next.render('/') | ||
expect(html).toContain('hello world') | ||
}) | ||
|
||
// In case you need to test the response object | ||
it('should work with fetch', async () => { | ||
const res = await next.fetch('/') | ||
const html = await res.text() | ||
expect(html).toContain('hello world') | ||
}) | ||
} | ||
) |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Page() { | ||
return <p>hello world</p> | ||
} |