Skip to content

Commit

Permalink
Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed May 25, 2021
1 parent 2c6e751 commit ebbcf2b
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion test/integration/production/test/index.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-env jest */
/* global browserName */
import cheerio from 'cheerio'
import { existsSync } from 'fs'
import fs, { existsSync } from 'fs-extra'
import globOriginal from 'glob'
import {
nextServer,
renderViaHTTP,
Expand All @@ -24,6 +25,10 @@ import { join } from 'path'
import dynamicImportTests from './dynamic'
import processEnv from './process-env'
import security from './security'
import { promisify } from 'util'

const glob = promisify(globOriginal)

const appDir = join(__dirname, '../')
let appPort
let server
Expand Down Expand Up @@ -64,6 +69,23 @@ describe('Production Usage', () => {
expect(output.match(/Generating static pages/g).length).toBe(5)
})

it('should not contain currentScript usage for publicPath', async () => {
const globResult = await glob('webpack-*.js', {
cwd: join(appDir, '.next/static/chunks'),
})

if (!globResult || globResult.length !== 1) {
throw new Error('could not find webpack-hash.js chunk')
}

const content = await fs.readFile(
join(appDir, '.next/static/chunks', globResult[0]),
'utf8'
)

expect(content).not.toContain('.currentScript')
})

describe('With basic usage', () => {
it('should render the page', async () => {
const html = await renderViaHTTP(appPort, '/')
Expand Down

0 comments on commit ebbcf2b

Please sign in to comment.