Enabling local script execution
You can easily enable local execution by storing your browser check scripts in local folders and passing the path to the right script:@playwright/test
will run locally with npx playwright test
and remotely on Checkly without any modifications:
basic.spec.ts
scripts/snippets/shoppingCart.{js,ts}
contains a Page Object Model class encapsulating the logic for the store’s shopping cart page:
shopping.spec.ts
scripts/checkout.spec.{js,ts}
file is your Checkly check with the following content:
checkout.spec.ts
ShoppingCart
class from the ./snippets/shoppingCart
directory and uses its methods and locators within the test. This setup will work out of the box locally with npx playwright test
. If you’d like to use the external files in Checkly, you’ll need to declare them as a checkly_snippet
resource in your .tf
file:
What’s worth notingIf you’d like to store the snippet files in a different directory, using environment variables to define the paths for local and remote execution could be a solution.
- Checkly will infer the name for the snippet file based on the
name
property of the resource schema. Hence, it’s best to name it the same as the local file.- The
./snippets/
path is where Checkly will make your snippets available. Use this directory in your Terraform setup to keep things consistent.