A comprehensive test suite for validating Metric Insights API functionality. This repository helps you verify that your Metric Insights instance works correctly after upgrades and provides examples for creating your own tests.
Required Software:
- Node.js 18+ (Download here)
- Git (for cloning the repository)
- Playwright (installed automatically via
npm install, browsers installed separately)
Required Access:
- Access to a Metric Insights instance (v7.2.0+)
- Admin account credentials
- API Application credentials (ID and Key)
How to get API credentials:
- Login to your MI instance as administrator
- Navigate to Admin > System > External Applications
- Click "+ Create New Application"
- Save the Application ID and Application Key
# Clone the repository
git clone https://github.com/metricinsights/playwright-testing-guide.git
cd playwright-testing-guide
# Install dependencies (includes Playwright, TypeScript, and all required packages)
npm install
# Install Playwright browsers (first time only)
npx playwright install chromiumFor single environment:
cp .env.example .env.stagingFor multiple environments:
cp .env.example .env.dev
cp .env.example .env.staging
cp .env.example .env.productionEdit your .env file(s) with instance details, (see .env.example for all variables). Important: Never commit .env* files to version control! They are already in .gitignore.
Run a quick test to verify everything is configured correctly:
# Test authentication
npm test tests/auth/auth-admin.spec.tsUsing .env.staging:
# Run all tests
npm run test:dev staging tests/
# Run specific test file
npm run test:dev staging auth-admin.spec.ts
# Run specific directory
npm run test:dev staging tests/authProblem: Tests fail with URL-related errors
Solution: Check that BASE_URL in .env is set correctly and includes https://
Problem: Cannot authenticate
Solution:
- Verify
APPLICATION_IDandAPPLICATION_KEYare correct - Check that the API user has necessary permissions
- Ensure the admin user credentials are correct
- Issues: GitHub Issues
- Documentation: help.metricinsights.com
| Test Suite Version | MI Version | Status |
|---|---|---|
| 1.x | 7.2.0+ | ✅ Supported |
Always test against your specific MI version before relying on these tests in production.
Note: These tests create temporary test data (prefixed with "Playwright") and clean it up automatically. However, always run tests on non-production instances first to ensure they work correctly with your configuration.