Transcripted Summary

In this chapter, we'll see how to update the project configurations from Azure DevOps.

You may want to run a test project with slightly different configurations than what we have locally.

For example, we might be running the test on localhost when running locally, or we may want to generate a HTML test report locally.

If we run the same project in our pipeline, it may not give the desired results, so we may want to tweak some project configurations in our pipeline.

Say my application hasn't yet been deployed - I have my application running on localhost.

So far, I've been testing on localhost, and say I would like to continue testing on localhost even if my application is deployed.

In my code, I've pulled out the baseUrl and stored it in the cypress.json file, which contains my Cypress project configurations.

Because my baseUrl is here, my test files will use this baseUrl, and so the URL is no longer present in the test files.

I've also pushed this code to GitHub.

Now, if we run the pipeline, the tests are sure to fail.

We need to update the baseUrl in the pipeline to be able to run successfully.

Let's see how we can do that.

I'm in my release pipeline and we'll go to the task that's running our tests.

Now, to update the configurations in our project, we can add the --config flag.

Using this --config flag, we can set our override configuration values.

We need to override our baseUrl value, so now we'll have baseUrl=

Now the localhost baseUrl set in cypress.json would be updated to this URL - well, not really updated in the file, but instead of the value from cypress.json, this value will be used as baseUrl.

We can also have multiple values separated by commas.

If you have a lot of values that change between environments, then we can also create multiple configuration files - one config per environment.

So, we can have for the dev environment, and for the QA environment.

Then, we can make use of the --config file flag to send the config file we would like to use.

But as you might be thinking, these solutions are available for Cypress.

Similar solutions may or may not be available for the test framework you may be working with.

So, what we can do is we can create a fresh configuration file here in the pipeline itself.

Let's reset this.

Now for creating a file, we can make use of the File Creator task.

This task isn't provided by Microsoft.

It's available in the Marketplace and you can install it for free.

I already have it installed, so I'll go ahead and add it.

We'll place it before "Run Tests", and let's update the display name to "Update Configurations".

Our file path would be $(System.DefaultWorkingDirectory)/abs/e2e/cypress.json, and our content would be:

    "Reporter": "junit",
    "reporterOptions": {
        "mochaFile": "results/TEST-[hash].xml"

And, we would like to "Overwrite file if exists".

Let's save and run our release pipeline.

Our test passed, so our configuration file was updated with the one that we created in the pipeline.

Having the ability to update configurations from the pipeline provides lots of flexibility.


© 2024 Applitools. All rights reserved. Terms and Conditions Privacy Policy GDPR