Skip to content

Fix failing tests on Windows #1318

@jescalada

Description

@jescalada

Various tests are failing on Windows, likely due to differences in file paths:

Image

Here's the complete output on my end:

Details
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  test/plugin/plugin.test.ts > loading plugins from packages
Error: ENOENT: no such file or directory, lstat 'C:\Users\mahye\git-proxy\test\fixtures\test-package\node_modules'
 ❯ test/plugin/plugin.test.ts:123:5
    121|
    122|   afterAll(() => {
    123|     rmSync(join(testPackagePath, 'node_modules'), { recursive: true });
       |     ^
    124|   });
    125| });

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/13]⎯


⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Tests 12 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  test/ConfigLoader.test.ts > ConfigLoader > initialize > should initialize cache directory using env-paths
AssertionError: expected 'C:\Users\mahye\AppData\Local\git-prox…' to contain 'AppData/Local'

Expected: "AppData/Local"
Received: "C:\Users\mahye\AppData\Local\git-proxy-nodejs\Cache"

 ❯ test/ConfigLoader.test.ts:215:43
    213|         expect(configLoader.cacheDirPath).toContain('.cache');
    214|       } else if (process.platform === 'win32') {
    215|         expect(configLoader.cacheDirPath).toContain('AppData/Local');
       |                                           ^
    216|       }
    217|     });

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/13]⎯

 FAIL  test/plugin/plugin.test.ts > loading plugins from packages > CommonJS syntax > should load plugins that are the default export (module.exports = pluginObj)
AssertionError: expected +0 to be 1 // Object.is equality

- Expected
+ Received

- 1
+ 0

 ❯ timeout test/plugin/plugin.test.ts:20:43
     18|         const loader = new PluginLoader([join(testPackagePath, 'default-export.js')]);
     19|         await loader.load();
     20|         expect(loader.pushPlugins.length).toBe(1);
       |                                           ^
     21|         expect(loader.pushPlugins.every((p) => isCompatiblePlugin(p))).toBe(true);
     22|         expect(

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[3/13]⎯

 FAIL  test/plugin/plugin.test.ts > loading plugins from packages > CommonJS syntax > should load multiple plugins from a module that match the plugin class (module.exports = { pluginFoo, pluginBar })        
AssertionError: expected +0 to be 1 // Object.is equality

- Expected
+ Received

- 1
+ 0

 ❯ timeout test/plugin/plugin.test.ts:34:43
     32|         const loader = new PluginLoader([join(testPackagePath, 'multiple-export.js')]);        
     33|         await loader.load();
     34|         expect(loader.pushPlugins.length).toBe(1);
       |                                           ^
     35|         expect(loader.pullPlugins.length).toBe(1);
     36|         expect(loader.pushPlugins.every((p) => isCompatiblePlugin(p))).toBe(true);

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[4/13]⎯

 FAIL  test/plugin/plugin.test.ts > loading plugins from packages > CommonJS syntax > should load plugins that are subclassed from plugin classes
AssertionError: expected +0 to be 1 // Object.is equality

- Expected
+ Received

- 1
+ 0

 ❯ timeout test/plugin/plugin.test.ts:52:43
     50|         const loader = new PluginLoader([join(testPackagePath, 'subclass.js')]);
     51|         await loader.load();
     52|         expect(loader.pushPlugins.length).toBe(1);
       |                                           ^
     53|         expect(loader.pushPlugins.every((p) => isCompatiblePlugin(p))).toBe(true);
     54|         expect(

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[5/13]⎯

 FAIL  test/plugin/plugin.test.ts > loading plugins from packages > ESM syntax > should load plugins that are the default export (exports default pluginObj)
AssertionError: expected +0 to be 1 // Object.is equality

- Expected
+ Received

- 1
+ 0

 ❯ timeout test/plugin/plugin.test.ts:68:43
     66|         const loader = new PluginLoader([join(testPackagePath, 'esm-export.js')]);
     67|         await loader.load();
     68|         expect(loader.pushPlugins.length).toBe(1);
       |                                           ^
     69|         expect(loader.pushPlugins.every((p) => isCompatiblePlugin(p))).toBe(true);
     70|         expect(

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[6/13]⎯

 FAIL  test/plugin/plugin.test.ts > loading plugins from packages > ESM syntax > should load multiple plugins from a module that match the plugin class (exports default { pluginFoo, pluginBar })
AssertionError: expected +0 to be 1 // Object.is equality

- Expected
+ Received

- 1
+ 0

 ❯ test/plugin/plugin.test.ts:79:41
     77|       const loader = new PluginLoader([join(testPackagePath, 'esm-multiple-export.js')]);      
     78|       await loader.load();
     79|       expect(loader.pushPlugins.length).toBe(1);
       |                                         ^
     80|       expect(loader.pullPlugins.length).toBe(1);
     81|       expect(loader.pushPlugins.every((p) => isCompatiblePlugin(p))).toBe(true);

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[7/13]⎯

 FAIL  test/plugin/plugin.test.ts > loading plugins from packages > ESM syntax > should load plugins that are subclassed from plugin classes (exports default class DummyPlugin extends PushActionPlugin {})    
AssertionError: expected +0 to be 1 // Object.is equality

- Expected
+ Received

- 1
+ 0

 ❯ test/plugin/plugin.test.ts:92:41
     90|       const loader = new PluginLoader([join(testPackagePath, 'esm-subclass.js')]);
     91|       await loader.load();
     92|       expect(loader.pushPlugins.length).toBe(1);
       |                                         ^
     93|       expect(loader.pushPlugins.every((p) => isCompatiblePlugin(p))).toBe(true);
     94|       expect(

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[8/13]⎯

 FAIL  test/processors/writePack.test.ts > writePack > exec > should execute git receive-pack with correct parameters
AssertionError: expected 1st "spawnSync" call to have been called with [ 'git', [ 'config', …(2) ], …(1) ]

- Expected
+ Received

@@ -3,9 +3,10 @@
    [
      "config",
      "receive.unpackLimit",
      "0",
    ],
-   ObjectContaining {
-     "cwd": "/path/to/repo",
+   {
+     "cwd": "\\path\\to\\repo",
+     "encoding": "utf-8",
    },
  ]

 ❯ test/processors/writePack.test.ts:65:29
     63|
     64|       expect(spawnSyncMock).toHaveBeenCalledTimes(2);
     65|       expect(spawnSyncMock).toHaveBeenNthCalledWith(
       |                             ^
     66|         1,
     67|         'git',

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[9/13]⎯

 FAIL  test/preReceive/preReceive.test.ts > Pre-Receive Hook Execution > should approve push automatically when hook returns status 0
AssertionError: expected true to be false // Object.is equality

- Expected
+ Received

- false
+ true

 ❯ test/preReceive/preReceive.test.ts:93:35
     91|
     92|     expect(result.steps).toHaveLength(1);
     93|     expect(result.steps[0].error).toBe(false);
       |                                   ^
     94|     expect(
     95|       result.steps[0].logs.some((log: string) =>

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[10/13]⎯

 FAIL  test/preReceive/preReceive.test.ts > Pre-Receive Hook Execution > should reject push automatically when hook returns status 1
AssertionError: expected true to be false // Object.is equality

- Expected
+ Received

- false
+ true

 ❯ test/preReceive/preReceive.test.ts:109:35
    107|
    108|     expect(result.steps).toHaveLength(1);
    109|     expect(result.steps[0].error).toBe(false);
       |                                   ^
    110|     expect(
    111|       result.steps[0].logs.some((log: string) =>

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[11/13]⎯

 FAIL  test/preReceive/preReceive.test.ts > Pre-Receive Hook Execution > should execute hook successfully and require manual approval
AssertionError: expected true to be false // Object.is equality

- Expected
+ Received

- false
+ true

 ❯ test/preReceive/preReceive.test.ts:125:35
    123|
    124|     expect(result.steps).toHaveLength(1);
    125|     expect(result.steps[0].error).toBe(false);
       |                                   ^
    126|     expect(
    127|       result.steps[0].logs.some((log: string) => log.includes('Push requires manual approval.'…

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[12/13]⎯

 FAIL  test/preReceive/preReceive.test.ts > Pre-Receive Hook Execution > should handle unexpected hook status codes
AssertionError: expected false to be true // Object.is equality

- Expected
+ Received

- true
+ false

 ❯ test/preReceive/preReceive.test.ts:142:7
    140|     expect(
    141|       result.steps[0].logs.some((log: string) => log.includes('Unexpected hook status: 99')),  
    142|     ).toBe(true);
       |       ^
    143|     expect(
    144|       result.steps[0].logs.some((log: string) => log.includes('Unknown pre-receive hook error.…

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[13/13]⎯


 Test Files  4 failed | 41 passed | 1 skipped (46)
      Tests  12 failed | 518 passed | 9 skipped (539)
   Start at  14:09:11
   Duration  36.85s (transform 1.65s, setup 0ms, collect 4.72s, tests 29.56s, environment 0ms, prepare 254ms)

We should fix these up so they're platform-agnostic, and also have a separate test script for running tests on Windows.

Related, another similar issue with E2E tests failing only on Windows:
#1165 (review)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions