Skip to content

Commit

Permalink
add additional test
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer committed Oct 16, 2020
1 parent 459b17d commit 1dd9e97
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions test/integration/relay-analytics/test/disabled.test.js
@@ -1,21 +1,28 @@
/* eslint-env jest */

import { join } from 'path'
import fs from 'fs-extra'
import { findPort, killApp, nextBuild, nextStart } from 'next-test-utils'
import webdriver from 'next-webdriver'
import { killApp, findPort, nextBuild, nextStart } from 'next-test-utils'
import path, { join } from 'path'

const appDir = join(__dirname, '../')
let appPort
let server
jest.setTimeout(1000 * 60 * 2)

let buildManifest

describe('Analytics relayer (disabled)', () => {
let stdout
beforeAll(async () => {
appPort = await findPort()
;({ stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
buildManifest = require(path.join(
appDir,
'.next/build-manifest.json'
), 'utf8')
server = await nextStart(appDir, appPort)
})
afterAll(() => killApp(server))
Expand Down Expand Up @@ -43,4 +50,23 @@ describe('Analytics relayer (disabled)', () => {

await browser.close()
})

it('Does not include the code', async () => {
const pageFiles = [
...new Set([
...buildManifest.pages['/'].filter((file) => file.endsWith('.js')),
...buildManifest.pages['/_app'].filter((file) => file.endsWith('.js')),
]),
]

expect(pageFiles.length).toBeGreaterThan(1)

for (const pageFile of pageFiles) {
const content = await fs.readFile(
path.join(appDir, '.next', pageFile),
'utf8'
)
expect(content).not.toMatch('vercel-analytics')
}
})
})

0 comments on commit 1dd9e97

Please sign in to comment.