Skip to main content

Four Reasons You Need Preview Environments

6 min read
Arsh Sharma
Developer Experience Engineer
A Preview Environment and four reasons to use it: collaboration, feedback, validation, and testing

There has been a rapid increase in the adoption of Preview Environments across organizations. From open-source projects to enterprise organizations, everyone seems to agree on their usefulness in helping ship applications faster. If you're not familiar with Preview Environments, they basically deploy the changes present in a Pull Request (PR) or Merge Request and provide a shareable link to access them!

Preview Environments provide an excellent way to not only validate that everything is working as expected but also allow everyone in the team to be a part of the feedback process. In this article, I’m going to give you four reasons which make them a must-have if you're looking to boost productivity across your team!

Reason 1: Bring Everyone on Board​

Feedback is one of the most crucial aspects of the software delivery process. Great feedback can come from anyone and not just engineers. But conventionally, the feedback process has always been limited to the software engineers on the team because it involved being able to read code. Even for technical team members, the feedback process hasn’t always been convenient. If you want to see how changes actually look and try things out, you would have to pull the code and build it, which is a time taking process.

Preview Environments solve both these problems by deploying the changes in a pull request and giving you a link that you can visit to view these deployed changes. This link is shareable, which means you can send it to anyone across your organization - product, marketing, sales, and even customers if need be! Not only does this allow a much wider set of people to be a part of the review process, but it also makes reviewing easier for everyone. Nobody needs to build the code or wait for a staging environment to try the new features or verify that that nasty bug blocking your users has indeed been fixed!

Reason 2: Feedback at the Right Time​

I think you will agree with me when I say that the early we're able to give feedback, the better. Often feedback from non-technical teams in software companies comes too late in the delivery cycle. It is often just before the release (or sometimes even after 💀) when you're testing things in a staging environment that you would show it to product, marketing, sales, and other teams. But the problem with this is that the feedback you get at this point is much harder to act on than if it were given right when chunks of code were being merged. Preview Environments solve this problem by allowing everyone to review things early on. They provide an excellent way to cut short iteration time by allowing early feedback.

Preview Environments follow the lifecycle of a pull request. They allow you to show the changes in a pull request or merge request before it gets merged. This way, you're able to get feedback for each pushed commit and make the required changes. This is so much easier than getting feedback in staging environments right before the release. Without Preview Environments, feedback early on is only possible from people who can read code, and others are left out of this very important process.

Reason 3: Validation That Things Work​

If multiple people have been pushing commits to the same branch, Preview Environments provide you a way to see the complete change together deployed live and be sure that things are as expected when you make a PR. But it’s not only this; even if you’re working on a branch alone, Preview Environments have become essential because of how complex our applications have grown.

Before a team has Preview Environments, it is very hard to know if the code works as expected or not. Sure, you can look at the code and review it syntactically, but when you start the application, maybe it doesn’t start. Maybe the helm chart you have for your application uses a variable different from the one you used in your code. Preview Environments do an excellent job of highlighting errors like these which are very hard to catch otherwise. When you have multiple services, and there is information flowing through a bunch of different things like databases, secrets, and whatnot, then validating that the changes in a PR still work with the rest of the application becomes a very tough job. Preview Environments help you provide this certainty that things work by deploying your changes and letting you see them!

Reason 4: Testing Your Code Better​

Preview Environments are where your CI tests run. Your pipeline doesn't create a separate environment to test a Pull Request or Merge Request: it deploys the Preview Environment and runs your tests against it, for example the Test Containers you run with okteto test. The environment your reviewers open is the same one your tests ran in.

This expands the kind of tests you can run. Without a running copy of the application, CI/CD is mostly limited to unit and integration tests, and end-to-end (E2E) tests get left out, because they require your entire application to be brought up. Preview Environments bring up the application with your changes just like it would be deployed in production, so you can run all sorts of E2E tests. Preview Environments also allow you to run testing frameworks like Cypress and Selenium, which require the application to be brought up. If you’re working with APIs, the URL that Preview Environments provide can also be used to test them end-to-end using tools like Postman.

And when a test fails, the Preview Environment is still running: open it, check the logs and the endpoints, and troubleshoot the failure in the same environment where it happened, instead of trying to reproduce it on your machine.

Conclusion​

To sum up, Preview Environments are a great way to easily get validation and feedback from everyone across your organization in a timely manner! As our applications continue to grow more complex, it becomes essential to rely on them for faster iterations if you’re looking to ship code timely.

Subscribe to our newsletter

What we learn running development environments and coding agents on Kubernetes, in your inbox.

About Okteto

Okteto gives every developer, coding agent and pull request an on-demand environment on your Kubernetes.