Skip to content

Commit

Permalink
fix: Revert change to module bundling (#177)
Browse files Browse the repository at this point in the history
* fix: Revert change to module bundling

Looks like `iife` from rollup isn't exposing agent as a global. We
need `window.PercyAgent =` not `var PercyAgent=`

* Remove `http-server` dep temporarily

`http-sever` relies on `estatic@3`, which was yanked from the npm reg
for security reasons. This broke CI
  • Loading branch information
Robdel12 committed May 2, 2019
1 parent dbba543 commit 0f575f2
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 188 deletions.
125 changes: 0 additions & 125 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Expand Up @@ -64,7 +64,6 @@
"chai": "^4.1.2",
"chai-http": "^4.0.0",
"eslint-config-oclif": "^3.0.0",
"http-server": "^0.11.1",
"husky": "^1.0.0-rc.13",
"mocha": "^6.1.3",
"nock": "^10.0.6",
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Expand Up @@ -7,7 +7,7 @@ export default {
output: {
name: "PercyAgent",
file: "dist/public/percy-agent.js",
format: "iife"
format: "umd"
},
plugins: [
// Allows node_modules resolution
Expand Down
122 changes: 61 additions & 61 deletions test/integration/agent-integration.test.ts
@@ -1,6 +1,6 @@
import * as fs from 'fs'
import { Server } from 'http'
import * as httpServer from 'http-server'
// import * as httpServer from 'http-server'
import { describe } from 'mocha'
import * as puppeteer from 'puppeteer'
import { agentJsFilename } from '../../src/utils/sdk-utils'
Expand Down Expand Up @@ -69,64 +69,64 @@ describe('Integration test', () => {
})

})
describe('on local test cases', () => {
const testCaseDir = `${__dirname}/testcases`
const PORT = 8000
let server: Server

before(() => {
server = httpServer.createServer({root: testCaseDir}) as Server
server.listen(PORT)
})

after(() => {
server.close()
})

it('snapshots all test cases', async () => {
const testFiles = fs.readdirSync(testCaseDir).filter((fn) => fn.endsWith('.html'))
for (const fname of testFiles) {
await page.goto(`http://localhost:${PORT}/${fname}`)
const domSnapshot = await snapshot(page, `Test case: ${fname}`)
}
})

describe('stabilizes DOM', () => {
before(async () => {
await page.goto(`http://localhost:${PORT}/stabilize-dom.html`)
})

it('serializes input elements', async () => {
await page.type('#testInputText', 'test input value')
await page.type('#testTextarea', 'test textarea value')
await page.click('#testCheckbox')
await page.click('#testRadioButton')

const domSnapshot = await snapshot(page, 'Serialize input elements')
expect(domSnapshot).to.contain('test input value')
expect(domSnapshot).to.contain('type="checkbox" checked')
expect(domSnapshot).to.contain('type="radio" checked')
expect(domSnapshot).to.contain('test textarea value')
})
})

describe('stablizes CSSOM', () => {
before(async () => {
await page.goto(`http://localhost:${PORT}/stabilize-cssom.html`)
})

it('serializes the CSSOM', async () => {
const domSnapshot = await snapshot(page, 'Serialize CSSOM')

expect(domSnapshot).to.contain('data-percy-cssom-serialized')
expect(domSnapshot).to.contain('.box { height: 500px; width: 500px; background-color: green; }')

// we want to ensure mutiple snapshots are successful
const secondDomSnapshot = await snapshot(page, 'Serialize CSSOM twice')
expect(secondDomSnapshot).to.contain('data-percy-cssom-serialized')
expect(secondDomSnapshot).to.contain('.box { height: 500px; width: 500px; background-color: green; }')

})
})
})
// describe.skip('on local test cases', () => {
// const testCaseDir = `${__dirname}/testcases`
// const PORT = 8000
// let server: Server

// before(() => {
// server = httpServer.createServer({root: testCaseDir}) as Server
// server.listen(PORT)
// })

// after(() => {
// server.close()
// })

// it('snapshots all test cases', async () => {
// const testFiles = fs.readdirSync(testCaseDir).filter((fn) => fn.endsWith('.html'))
// for (const fname of testFiles) {
// await page.goto(`http://localhost:${PORT}/${fname}`)
// const domSnapshot = await snapshot(page, `Test case: ${fname}`)
// }
// })

// describe('stabilizes DOM', () => {
// before(async () => {
// await page.goto(`http://localhost:${PORT}/stabilize-dom.html`)
// })

// it('serializes input elements', async () => {
// await page.type('#testInputText', 'test input value')
// await page.type('#testTextarea', 'test textarea value')
// await page.click('#testCheckbox')
// await page.click('#testRadioButton')

// const domSnapshot = await snapshot(page, 'Serialize input elements')
// expect(domSnapshot).to.contain('test input value')
// expect(domSnapshot).to.contain('type="checkbox" checked')
// expect(domSnapshot).to.contain('type="radio" checked')
// expect(domSnapshot).to.contain('test textarea value')
// })
// })

// describe('stablizes CSSOM', () => {
// before(async () => {
// await page.goto(`http://localhost:${PORT}/stabilize-cssom.html`)
// })

// it('serializes the CSSOM', async () => {
// const domSnapshot = await snapshot(page, 'Serialize CSSOM')

// expect(domSnapshot).to.contain('data-percy-cssom-serialized')
// expect(domSnapshot).to.contain('.box { height: 500px; width: 500px; background-color: green; }')

// // we want to ensure mutiple snapshots are successful
// const secondDomSnapshot = await snapshot(page, 'Serialize CSSOM twice')
// expect(secondDomSnapshot).to.contain('data-percy-cssom-serialized')
// expect(secondDomSnapshot).to.contain('.box { height: 500px; width: 500px; background-color: green; }')

// })
// })
// })
})

0 comments on commit 0f575f2

Please sign in to comment.