checkly / headless-recorder

Chrome extension that records your browser interactions and generates a Playwright or Puppeteer script.
https://checklyhq.com/headless-recorder
MIT License
15.03k stars 722 forks source link

Feat anscestor attributes #61

Closed ephetic closed 5 years ago

ephetic commented 5 years ago

Description

Updates use of @medv/finder to include [data-qa="xxx"] attributes throughout selector, not just on the clicked element. This maximizes the value of the custom attribute setting. See issue #52.

Type of change

Please delete options that are not relevant.

How Has This Been Tested?

A test has been created that shows clicking on a descendent span records a selector like

'body > #content-root > [data-qa="article-wrapper"] > [data-qa="article-body"] > span'

Existing tests unaffected.

Checklist:

ephetic commented 5 years ago

Seeing test flakiness. Hold off on this for now.

ephetic commented 5 years ago

Okay, it looks like running the jest tests in parallel upsets the express server (EADDRINUSE) such that the race causes one or both (?) servers to fail, failing those tests. This is how I've fixed it locally (with commensurate changes to the test files that call this helper)

export const startServer = function (buildDir, file) {
  return new Promise((resolve, reject) => {
    const app = express()
    app.use('/build', express.static(path.join(__dirname, buildDir)))
    app.get('/', (req, res) => {
      res.status(200).sendFile(file, { root: __dirname })
    })
    let server
    let port
    const retry = (e) => {
      if(e.code == 'EADDRINUSE') {
        setTimeout(() => connect, 1000)
      }
    }
    const connect = () => {
      port = 0|(Math.random() * 1000) + 3000
      server = app.listen(port)
      server.once('error', retry)
      server.once('listening', () => {
        return resolve({server, port})
      })
    }
    connect()
  })
}
tnolet commented 5 years ago

Hey @ephetic this looks great, I'll have time to look at it earliest somewhere next week. Sorry for the delay.

tnolet commented 5 years ago

@ephetic LGTM I'm merging it and will push a point release.