File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33 * We are setting the VITEST env var in vitest.config.ts for unit tests.
44 */
55export const isUnitTest = ( ) => {
6- return typeof process !== 'undefined' && ! ! process . env [ 'VITEST' ] === 'true'
6+ return typeof process !== 'undefined' && process . env [ 'VITEST' ] === 'true'
77}
88
99export const isE2eTest = ( ) => {
@@ -14,8 +14,19 @@ export const isE2eTest = () => {
1414 return false
1515}
1616
17+ /**
18+ * This is the same logic as the environmentServer isE2eTest()
19+ * method, for use in API endpoint serverless functions.
20+ */
21+ export const isE2eTestLambda = ( ) => {
22+ return typeof process !== 'undefined' && process . env [ 'PLAYWRIGHT' ] === 'true'
23+ }
24+
25+ /**
26+ * Correctly handle checking for e2e test mode in API endpoint serverless functions
27+ */
1728export const isTest = ( ) => {
18- return isUnitTest ( ) || isE2eTest ( )
29+ return isUnitTest ( ) || isE2eTest ( ) || isE2eTestLambda ( )
1930}
2031
2132export const isDev = ( ) => {
Original file line number Diff line number Diff line change @@ -27,15 +27,15 @@ export const isCI = () => {
2727 * We are setting the VITEST env var in vitest.config.ts for unit tests.
2828 */
2929export const isUnitTest = ( ) => {
30- return process . env [ 'VITEST' ] ? true : false
30+ return process . env [ 'VITEST' ] === 'true' ? true : false
3131}
3232
3333/**
3434 * Environmental variable "PLAYWRIGHT" is set in a setup
3535 * script called by Playwright's globalSetup config hook
3636 */
3737export const isE2eTest = ( ) => {
38- return process . env [ 'PLAYWRIGHT' ] ? true : false
38+ return process . env [ 'PLAYWRIGHT' ] === ' true'
3939}
4040
4141export const isTest = ( ) => {
You can’t perform that action at this time.
0 commit comments