-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
46 additions
and
2 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
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
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,41 @@ | ||
import * as fs from 'fs' | ||
import { RUM_BUNDLE } from '../../lib/framework' | ||
import { APPLICATION_ID, CLIENT_TOKEN } from '../../lib/helpers/configuration' | ||
|
||
describe('Inject RUM with Puppeteer', () => { | ||
// S8s tests inject RUM with puppeteer evaluateOnNewDocument | ||
it('should not throw error in chrome', async () => { | ||
const isInjected = await injectRumWithPuppeteer() | ||
expect(isInjected).toBe(true) | ||
}) | ||
}) | ||
|
||
async function injectRumWithPuppeteer() { | ||
const ddRUM = fs.readFileSync(RUM_BUNDLE, 'utf8') | ||
const puppeteerBrowser = await browser.getPuppeteer() | ||
let injected = true | ||
|
||
await browser.call(async () => { | ||
const page = await puppeteerBrowser.newPage() | ||
await page.evaluateOnNewDocument( | ||
` | ||
if (location.href !== 'about:blank') { | ||
${ddRUM} | ||
window.DD_RUM._setDebug(true) | ||
window.DD_RUM.init({ | ||
applicationId: ${APPLICATION_ID}, | ||
clientToken: ${CLIENT_TOKEN}, | ||
}) | ||
window.DD_RUM.startView() | ||
} | ||
` | ||
) | ||
page.on('console', (msg) => { | ||
if (msg.type() === 'error') { | ||
injected = false | ||
} | ||
}) | ||
await page.goto('https://webdriver.io') | ||
}) | ||
return injected | ||
} |
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