Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
juan-fernandez committed Oct 30, 2024
1 parent 91c4371 commit 0ea9afc
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion packages/datadog-instrumentations/src/playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ function testBeginHandler (test, browserName) {
const testAsyncResource = new AsyncResource('bound-anonymous-fn')
testToAr.set(test, testAsyncResource)
testAsyncResource.runInAsyncScope(() => {
testStartCh.publish({ testName, testSuiteAbsolutePath, testSourceLine, browserName })
// testStartCh.publish({ testName, testSuiteAbsolutePath, testSourceLine, browserName })
})
}

Expand Down Expand Up @@ -567,3 +567,38 @@ addHook({

return loadUtilsPackage
})

// Only in worker
addHook({
name: 'playwright',
file: 'lib/worker/workerMain.js',
versions: ['>=1.38.0']
}, (workerPackage) => {
shimmer.wrap(workerPackage.WorkerMain.prototype, '_runTest', _runTest => async function (test, retry) {
const {
_requireFile: testSuiteAbsolutePath,
title: testName,
location: {
line: testSourceLine
}
} = test
let res

// If test events are created in the worker process I need to stop creating it in the main process
// Probably yet another test worker exporter is needed in addition to the ones for mocha, jest and cucumber
// it's probably hard to tell that's a playwright worker though, as I don't think there is a specific env variable
const testAsyncResource = new AsyncResource('bound-anonymous-fn')
testAsyncResource.runInAsyncScope(() => {
// TODO: clear browserName
testStartCh.publish({ testName, testSuiteAbsolutePath, testSourceLine, browserName: 'chromium' })
res = _runTest.apply(this, arguments)
})
return res
})

shimmer.wrap(workerPackage.WorkerMain.prototype, 'dispatchEvent', dispatchEvent => function (event) {
// Do I augment the testBegin event to include the test span id? Or do I create the test events in the worker process?

Check failure on line 600 in packages/datadog-instrumentations/src/playwright.js

View workflow job for this annotation

GitHub Actions / lint

This line has a length of 122. Maximum allowed is 120
return dispatchEvent.apply(this, arguments)
})
return workerPackage
})

0 comments on commit 0ea9afc

Please sign in to comment.