Comments (7)
@puskuruk I think it'd be nice to allow importing custom runner extensions so that use case/app-specific logic could be implemented. But I think it's something that we need to take a look into!
from replay.
Hey, thanks for the feature request. How would it work if the recording involves multiple domains? I guess using this variable might result in a broken recording in that case?
from replay.
Thank you @OrKoN
Yes, when you have multiple domains it'll fail. In our case we deploy our application to different environments and I wanted be able to test those environments with replacing base URLs.
How we can improve this implementation?
from replay.
In our codebase,I solved this problem with a custom runner but I thought using an environment variable is more straightforward solution. Because it's a common practice.
https://playwright.dev/docs/test-advanced
https://docs.cypress.io/guides/references/best-practices#Setting-a-global-baseUrl
/**
* Run a recording from a json file
* @param {string} recordingPath
* @param {Extension} extension
*/
async function runRecording(recordingPath, extension) {
const content = await fs.readFile(recordingPath, 'utf8');
const object = JSON.parse(content);
const recordingWithBaseURL = addBaseURLToRecording(object);
const recording = parse(recordingWithBaseURL);
const runner = await createRunner(recording, extension);
await runner.run();
}
But importing custom runner extensions also makes sense, and I can implement this feature ๐
from replay.
I see! Thanks for sharing those. It looks like in other frameworks it works differently in an important way: baseUrl applies only to the relative URLs in the script and does not rewrite absolute URLs. We currently don't support relative URLs though. I think we will need some time to re-think the UX here, so thanks for the feedback!
from replay.
The issue for us is that the starting url may and usually is different from where we want to run the tests. This wouldn't be an issue if we were only testing production, but we test PRs, development, staging, and local environments, all with different URLs. This allows us to catch bugs before going to production.
It seems like there is an implicit starting url with the first navigate step. One idea would be if there's a BASE_URL
defined, then we could override the starting url of a recording's first step and any subsequent URL bases which match the starting URL. Something like this:
Recording 1
steps: [
{
"type": "navigate",
"url": "http://localhost:3001/doawesome",
...
},
...
{
"type": "navigate",
"url": "http://someotherurl.com",
...
},
...
{
"type": "navigate",
"url": "http://localhost:3001/doawesome",
...
},
]
Recording 2
steps: [
{
"type": "navigate",
"url": "http://localhost:3008/doawesome",
...
},
...
{
"type": "navigate",
"url": "http://someotherurl.com",
...
},
...
{
"type": "navigate",
"url": "http://localhost:3008/doawesome",
...
},
]
With a BASE_URL = website.ftw
these would become:
Recording 1
steps: [
{
"type": "navigate",
"url": "http://website.ftw/doawesome",
...
},
...
{
"type": "navigate",
"url": "http://someotherurl.com",
...
},
...
{
"type": "navigate",
"url": "http://website.ftw/doawesome",
...
},
]
Recording 2
steps: [
{
"type": "navigate",
"url": "http://website.ftw/doawesome",
...
},
...
{
"type": "navigate",
"url": "http://someotherurl.com",
...
},
...
{
"type": "navigate",
"url": "http://website.ftw/doawesome",
...
},
]
Thoughts on this approach?
from replay.
Since we have a solution to modify URLs with an extension we can close this issue. ๐
Example implementation:
const { PuppeteerRunnerExtension } = require('@puppeteer/replay')
class Extension extends PuppeteerRunnerExtension {
async runStep(step, flow) {
if ('url' in step) {
// modify URL here
// reassign step here
}
await super.runStep(step, flow)
}
}
from replay.
Related Issues (20)
- msfs2020map-enhancement HOT 2
- R
- iPhone
- Sแปญa lแปi
- Tt
- Lmao fuck all you bitches you are smart I give it to ya but just not smart enough now run away because all that s has been copied and turned into the fbi
- I'm here forever
- Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
- Hacking phone HOT 1
- [Spam]
- Need help. My X is SALNT_B please help. My sister and family man. Why!!
- What the fuck.
- Wasa
- My white cat
- Hello, I'm Mauressa Addington
- F
- Experience expected
- All
- e594f50174507c03dfd2e04fe70b2bc04f69773d
- Aman
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from replay.