Unverified Commit 44c5886c authored by JJ Kasper's avatar JJ Kasper Committed by GitHub
parent 5160aa72
...@@ -214,7 +214,7 @@ describe('page features telemetry', () => { ...@@ -214,7 +214,7 @@ describe('page features telemetry', () => {
} }
}) })
it('detect reportWebVitals correctly for `next build`', async () => { it('detects reportWebVitals with no _app correctly for `next build`', async () => {
// Case 1: When _app.js does not exist. // Case 1: When _app.js does not exist.
let build = await nextBuild(appDir, [], { let build = await nextBuild(appDir, [], {
stderr: true, stderr: true,
...@@ -225,7 +225,9 @@ describe('page features telemetry', () => { ...@@ -225,7 +225,9 @@ describe('page features telemetry', () => {
.exec(build.stderr) .exec(build.stderr)
.pop() .pop()
expect(event1).toMatch(/hasReportWebVitals.*?false/) expect(event1).toMatch(/hasReportWebVitals.*?false/)
})
it('detect with reportWebVitals correctly for `next build`', async () => {
// Case 2: When _app.js exist with reportWebVitals function. // Case 2: When _app.js exist with reportWebVitals function.
await fs.utimes( await fs.utimes(
path.join(appDir, 'pages', '_app_withreportwebvitals.empty'), path.join(appDir, 'pages', '_app_withreportwebvitals.empty'),
...@@ -237,7 +239,7 @@ describe('page features telemetry', () => { ...@@ -237,7 +239,7 @@ describe('page features telemetry', () => {
path.join(appDir, 'pages', '_app.js') path.join(appDir, 'pages', '_app.js')
) )
build = await nextBuild(appDir, [], { const build = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: 1 },
}) })
...@@ -247,9 +249,13 @@ describe('page features telemetry', () => { ...@@ -247,9 +249,13 @@ describe('page features telemetry', () => {
path.join(appDir, 'pages', '_app_withreportwebvitals.empty') path.join(appDir, 'pages', '_app_withreportwebvitals.empty')
) )
event1 = /NEXT_BUILD_OPTIMIZED[\s\S]+?{([\s\S]+?)}/.exec(build.stderr).pop() const event1 = /NEXT_BUILD_OPTIMIZED[\s\S]+?{([\s\S]+?)}/
.exec(build.stderr)
.pop()
expect(event1).toMatch(/hasReportWebVitals.*?true/) expect(event1).toMatch(/hasReportWebVitals.*?true/)
})
it('detect without reportWebVitals correctly for `next build`', async () => {
// Case 3: When _app.js exist without reportWebVitals function. // Case 3: When _app.js exist without reportWebVitals function.
await fs.utimes( await fs.utimes(
path.join(appDir, 'pages', '_app_withoutreportwebvitals.empty'), path.join(appDir, 'pages', '_app_withoutreportwebvitals.empty'),
...@@ -261,7 +267,7 @@ describe('page features telemetry', () => { ...@@ -261,7 +267,7 @@ describe('page features telemetry', () => {
path.join(appDir, 'pages', '_app.js') path.join(appDir, 'pages', '_app.js')
) )
build = await nextBuild(appDir, [], { const build = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: 1 },
}) })
...@@ -271,7 +277,9 @@ describe('page features telemetry', () => { ...@@ -271,7 +277,9 @@ describe('page features telemetry', () => {
path.join(appDir, 'pages', '_app_withoutreportwebvitals.empty') path.join(appDir, 'pages', '_app_withoutreportwebvitals.empty')
) )
event1 = /NEXT_BUILD_OPTIMIZED[\s\S]+?{([\s\S]+?)}/.exec(build.stderr).pop() const event1 = /NEXT_BUILD_OPTIMIZED[\s\S]+?{([\s\S]+?)}/
.exec(build.stderr)
.pop()
expect(event1).toMatch(/hasReportWebVitals.*?false/) expect(event1).toMatch(/hasReportWebVitals.*?false/)
}) })
}) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment