nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.62k stars 2.36k forks source link

Cypress claims nx is unsupported library in component testing on Github Action #20525

Closed konrad-szczepaniak-esky closed 11 months ago

konrad-szczepaniak-esky commented 11 months ago

Current Behavior

I try to configure component testing on github actions using container option with node v18. Unfortunately, cypress returns information about unsupported lib: nx. This error didn't occur on local machine.

I tried cypress v12 and v13, results were the same.

Expected Behavior

Component-testing should run without any problem

GitHub Repo

No response

Steps to Reproduce

Github action job

jobs:
  pr_test_component:
    runs-on: k8s-runner
    container:
      image: [[node-img-path]]/node18-cli:latest
      credentials:
        [[cred]]
    steps:
      - name: Checkout PR
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Install Dependencies
        uses: ./.github/actions/install-dependencies
      - name: Prepare NX SHA
        uses: nrwl/nx-set-shas@v4
        with:
          main-branch-name: master
          workflow-id: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
      - name: check Master
        run: git branch --track master origin/master
      - name: Run component tests
        run: npx nx affected -t component-test --parallel=1 --record=false --watch=false

cypress config inside lib:

import { defineConfig } from 'cypress';
import { nxComponentTestingPreset } from '@nx/angular/plugins/component-testing';

export default defineConfig({
  component: nxComponentTestingPreset(__filename),
});

Nx Report

Node   : 18.17.1
   OS     : linux-x64
   npm    : 8.19.4

   nx                 : 16.10.0
   @nx/js             : 16.10.0
   @nx/jest           : 16.10.0
   @nx/linter         : 16.10.0
   @nx/workspace      : 16.10.0
   @nx/angular        : 16.10.0
   @nx/cypress        : 16.10.0
   @nx/devkit         : 16.10.0
   @nx/eslint-plugin  : 16.10.0
   @nx/storybook      : 16.10.0
   @nrwl/tao          : 16.10.0
   @nx/webpack        : 16.10.0
   typescript         : 5.1.6
   ---------------------------------------
   Community plugins:
   @nguniversal/builders       : 16.2.0
   @nguniversal/express-engine : 16.2.0
   @storybook/angular          : 7.5.3

Failure Logs

npx nx affected -t component-test --parallel=1 --record=false --watch=false

 >  NX   Running target component-test for 4 projects:

    - collection
    - inspiration
    - search
    - weather

   With additional flags:
     --record=false
     --watch=false

> nx run inspiration:component-test --record=false --watch=false

It looks like this is your first time using Cypress: 12.17.4

[STARTED] Task without title.
[SUCCESS] Task without title.

Opening Cypress...

DevTools listening on ws://127.0.0.1:35663/devtools/browser/24291993-4baf-4c51-8ea6-e66f81a4bc44

We've detected that you're using a 3rd party library that is not supported by Cypress: nx

To continue running Cypress, please remove this library and its configuration files or contact us for help migrating.

https://on.cypress.io/unsupported-third-party-library?b=w6jDsg%3D%3D

...
[4x same log]
...

 >  NX   Running target component-test for 4 projects failed

   Failed tasks:

   - inspiration:component-test
   - search:component-test
   - weather:component-test
   - collection:component-test

Error: Process completed with exit code 1.

Package Manager Version

8.19.4

Operating System

Additional Information

No response

FrozenPandaz commented 11 months ago

Hi @konrad-szczepaniak-esky Is there any chance you could provide a repo that shows this issue?

I've tried to reproduce this issue myself and I wasn't able to.

We will reach out to the Cypress team to see what's going on but please help us reproduce the issue.

jordanpowell88 commented 11 months ago

@konrad-szczepaniak-esky Thanks for surfacing this issue. After working with the team at Nx we found that this is actually not an issue in Nx itself but with how Cypress interfaces with Nx. We have identified the fix on Cypress's end and will try to get a fix out shortly. Is it possible for you to close the issue in here and re-open it in the Cypress repo?

In the time being you should just be able to remove the --record flag altogether and it should unblock you

FrozenPandaz commented 11 months ago

Thank you @jordanpowell88. I'm going to close this issue in favor of the issue in the cypress repo. Please link this issue when that issue is created.

github-actions[bot] commented 10 months ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.