Skip to content

Commit e98cad7

Browse files
fix(test runner): retain PWTEST_CACHE_DIR compatibility (#43802)
Co-authored-by: microsoft-playwright-automation[bot] <203992400+microsoft-playwright-automation[bot]@users.noreply.github.com>
1 parent f6f7803 commit e98cad7

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

‎packages/playwright/src/transform/compilationCache.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export type SerializedCompilationCache = {
4949
// - For workers-only dynamic imports or some cache problems, we will re-transpile files in
5050
// each worker anew.
5151

52-
export const cacheDir = process.env.PLAYWRIGHT_TRANSFORM_CACHE_DIR || (() => {
52+
export const cacheDir = process.env.PLAYWRIGHT_TRANSFORM_CACHE_DIR || process.env.PWTEST_CACHE_DIR || (() => {
5353
if (process.platform === 'win32')
5454
return path.join(os.tmpdir(), `playwright-transform-cache`);
5555
// Use `geteuid()` instead of more natural `os.userInfo().username`

‎tests/playwright-test/cache.spec.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,16 @@ test('should clear cache for ct', async ({ runCLICommand }) => {
5050
expect(result.exitCode).toBe(0);
5151
});
5252

53-
test('should automatically clean cached versions of a changed file', async ({ runInlineTest, writeFiles }) => {
53+
test('should automatically clean cached versions of a changed file', { annotation: { type: 'issue', description: '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/microsoft/playwright/issues/43798' } }, async ({ runInlineTest, writeFiles }) => {
5454
const cacheDir = test.info().outputPath('playwright-test-cache');
5555
await runInlineTest({
5656
'a.spec.ts': `
5757
import { test } from '@playwright/test';
5858
test('example', () => {});
5959
`,
6060
}, undefined, {
61-
PLAYWRIGHT_TRANSFORM_CACHE_DIR: cacheDir
61+
PLAYWRIGHT_TRANSFORM_CACHE_DIR: undefined,
62+
PWTEST_CACHE_DIR: cacheDir,
6263
});
6364

6465
const cacheDirectories = await fs.promises.readdir(cacheDir);
@@ -84,7 +85,8 @@ test('should automatically clean cached versions of a changed file', async ({ ru
8485
test('modified test', () => {});
8586
`,
8687
}, undefined, {
87-
PLAYWRIGHT_TRANSFORM_CACHE_DIR: cacheDir
88+
PLAYWRIGHT_TRANSFORM_CACHE_DIR: cacheDir,
89+
PWTEST_CACHE_DIR: test.info().outputPath('unused-cache'),
8890
});
8991

9092
cachedFiles = await fs.promises.readdir(testCacheDirectory);

0 commit comments

Comments
 (0)