diff --git a/.github/workflows/e2e-cache.yml b/.github/workflows/e2e-cache.yml
index a0f20639..424dcaf4 100644
--- a/.github/workflows/e2e-cache.yml
+++ b/.github/workflows/e2e-cache.yml
@@ -135,6 +135,44 @@ jobs:
         run: __tests__/verify-node.sh "${{ matrix.node-version }}"
         shell: bash
 
+  node-yarn4-corepack-dependencies-caching:
+    name: Test yarn 4 (Node ${{ matrix.node-version}}, ${{ matrix.os }})
+    runs-on: ${{ matrix.os }}
+    env:
+      YARN_ENABLE_IMMUTABLE_INSTALLS: false
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [ubuntu-latest, windows-latest, macos-latest]
+        node-version: [18, 20]
+    steps:
+      - uses: actions/checkout@v4
+      - name: Update yarn
+        run: yarn set version 4.1.0
+      - name: Yarn version
+        run: yarn --version
+      - name: Generate simple .yarnrc.yml
+        run: |
+          echo "nodeLinker: node-modules" >> .yarnrc.yml
+      - name: Generate yarn file
+        run: yarn install
+      - name: Remove dependencies
+        shell: pwsh
+        run: Remove-Item node_modules -Force -Recurse
+      - name: Clean global cache
+        run: yarn cache clean --all
+      - name: Setup Node
+        uses: ./
+        with:
+          node-version: ${{ matrix.node-version }}
+          cache: 'yarn'
+          corepack: true
+      - name: Install dependencies
+        run: yarn install
+      - name: Verify node and yarn
+        run: __tests__/verify-node.sh "${{ matrix.node-version }}"
+        shell: bash
+
   yarn-subprojects:
     name: Test yarn subprojects
     strategy:
diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts
index 97883cff..da025ce3 100644
--- a/__tests__/main.test.ts
+++ b/__tests__/main.test.ts
@@ -277,13 +277,13 @@ describe('main tests', () => {
     it('should not enable corepack when no input', async () => {
       inputs['corepack'] = '';
       await main.run();
-      expect(getCommandOutputSpy).not.toHaveBeenCalledWith('corepack');
+      expect(getCommandOutputSpy).not.toHaveBeenCalledWith(expect.stringContaining('corepack'));
     });
 
     it('should not enable corepack when input is "false"', async () => {
       inputs['corepack'] = 'false';
       await main.run();
-      expect(getCommandOutputSpy).not.toHaveBeenCalledWith('corepack');
+      expect(getCommandOutputSpy).not.toHaveBeenCalledWith(expect.stringContaining('corepack'));
     });
 
     it('should enable corepack when input is "true"', async () => {