Skip to content

Commit 0e24c26

Browse files
Apply suggestions from code review
1 parent f4486a4 commit 0e24c26

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

src/content/docs/turnstile/tutorials/excluding-turnstile-from-e2e-tests.mdx

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,22 @@ This tutorial explains how to handle Turnstile in your end-to-end (E2E) tests by
1818

1919
When running E2E tests, you often want to bypass or simplify the Turnstile verification process. Cloudflare provides official test credentials that always pass verification, making them perfect for testing environments:
2020

21-
- Test Sitekey: `1x00000000000000000000AA`
22-
- Test Secret Key: `1x0000000000000000000000000000000AA`
21+
- Test sitekey: `1x00000000000000000000AA`
22+
- Test secret key: `1x0000000000000000000000000000000AA`
2323

24-
For more details, see the [testing documentation](/turnstile/troubleshooting/testing/).
24+
For more details, refer to the [testing documentation](/turnstile/troubleshooting/testing/).
2525

26-
## ⚠️ Important Security Warning
26+
:::caution
2727

28-
Never use test credentials in production! Always ensure:
29-
1. Test credentials are only used in test environments
30-
2. Production credentials are properly protected
31-
3. Your deployment process prevents test credentials from reaching production
28+
Never use test credentials in production. Always ensure:
29+
- Test credentials are only used in test environments.
30+
- Production credentials are properly protected.
31+
- Your deployment process prevents test credentials from reaching production.
32+
:::
3233

33-
## Implementation Strategy
34+
## Implementation
3435

35-
The key to implementing test-environment detection is identifying test requests server-side. Here's a simple approach:
36+
The key to implementing test-environment detection is identifying test requests server-side. Here is a simple approach:
3637

3738
```typescript
3839
// Detect test environments using IP addresses or headers
@@ -60,7 +61,7 @@ function getTurnstileCredentials(request) {
6061
}
6162
```
6263

63-
## Server-side Integration
64+
## Server-side integration
6465

6566
When rendering your page, inject the appropriate sitekey based on the environment:
6667

@@ -71,38 +72,38 @@ app.get('/your-form', (req, res) => {
7172
});
7273
```
7374

74-
## Client-side Integration
75+
## Client-side integration
7576

7677
Your template can then use the injected sitekey:
7778

7879
```html
7980
<div class="turnstile" data-sitekey="<%= sitekey %>"></div>
8081
```
8182

82-
## Best Practices
83+
## Best practices
8384

84-
1. **Environment Detection**
85-
- Use multiple factors to identify test environments (IP, headers, etc.)
86-
- Keep test environment identifiers secure, if you need to test from the public web
85+
1. **Environment detection**
86+
- Use multiple factors to identify test environments (IP, headers, etc.).
87+
- Keep your test environment identifiers secure if you need to test from the public web.
8788

88-
2. **Credential Management**
89-
- Store production credentials securely (for example, in environment variables)
90-
- Never commit credentials to version control
91-
- Use different credentials for each environment
89+
2. **Credential management**
90+
- Store production credentials securely (for example, in environment variables).
91+
- Never commit credentials to version control.
92+
- Use different credentials for each environment.
9293

93-
3. **Deployment Safety**
94-
- Add checks to prevent test credentials in production
95-
- Include credential validation in your CI/CD pipeline
96-
- Monitor for accidental test credential usage
94+
3. **Deployment safety**
95+
- Add checks to prevent test credentials in production.
96+
- Include credential validation in your CI/CD pipeline.
97+
- Monitor for accidental test credential usage.
9798

98-
## Testing Considerations
99+
## Testing considerations
99100

100-
- Test credentials will always pass verification
101-
- They're perfect for automated testing environments
102-
- They help avoid rate limiting during testing
103-
- They make tests more predictable and faster
101+
- Test credentials will always pass verification.
102+
- They are perfect for automated testing environments.
103+
- They help avoid rate limiting during testing.
104+
- They make tests more predictable and faster.
104105

105-
## Example Test Setup
106+
## Example test setup
106107

107108
For Cypress or similar E2E testing frameworks:
108109

0 commit comments

Comments
 (0)