Giter VIP home page Giter VIP logo

Comments (10)

AgentEnder avatar AgentEnder commented on September 27, 2024 5

Hi there 👋 - so this is a bit more complex than one may imagine. Most typically getting this error during a unit test is a result of a test doing something that is causing the project graph to be created. You'll need to mock the project graph during these tests, and while that sounds rough its also going to give you much more accurate and repeatable tests.

Without mocking the graph, the tests will be running generators which create the project graph of the current Nx workspace and make some decisions about that. That's almost always not really what you want. We just recently fixed that behavior on the Nx repo.

This suddenly became a problem for some folks because several of our published generators do rely on the graph now.

You can see how we are mocking this in our unit test setup: https://github.com/nrwl/nx/blob/master/scripts/unit-test-setup.js

from nx.

hunhavoc avatar hunhavoc commented on September 27, 2024 2

Having the same issue. Tests run well on local Mac, but does not work on Linux env in CI.

from nx.

digitalhank avatar digitalhank commented on September 27, 2024

experiencing the same but with the applicationGenerator from '@nx/next' on v18.3.4

from nx.

pedroyan avatar pedroyan commented on September 27, 2024

I'm experiencing the same problem. Tests work on MacOS but not on our Linux CI.

It happens when I call the libraryGenerator function from @nx/nest@18.3.4 on a Jest test

from nx.

SuneRadich avatar SuneRadich commented on September 27, 2024

I have a similar issue with a Jest test also using the libraryGenerator. However, I see the error on both Github Actions / nx agents as well as on my Mac developer machine.

I also tried to copy paste the test in this issue and run the test, and it fails on my mac running Sonoma 14.4.1

from nx.

SuneRadich avatar SuneRadich commented on September 27, 2024

I got my test to run by following a workaround from mswjs/msw#1851

Object.defineProperties(globalThis, {
  performance: { value: performance, writable: true },
});

Not quite sure why it works, but my test runs again with this 'fix'.

from nx.

dasco144 avatar dasco144 commented on September 27, 2024

I'm having the same issue when wrapping the service schematic from @schematics/angular, and executing that.

Although, when running locally (MacOS) I get this error

ReferenceError: TextDecoder is not defined

      18 |
      19 |   const serviceGenerator = wrapAngularDevkitSchematic('@schematics/angular', 'service');
    > 20 |   await serviceGenerator(tree, serviceOptions);
         |   ^
      21 |

      at Object.<anonymous> (../../node_modules/@angular-devkit/schematics/src/rules/template.js:33:17)
      at Object.<anonymous> (../../node_modules/@angular-devkit/schematics/src/index.js:56:14)
      at Object.<anonymous> (../../node_modules/@angular-devkit/schematics/tools/file-system-engine-host-base.js:16:15)
      at Object.<anonymous> (../../node_modules/@angular-devkit/schematics/tools/index.js:27:14)
      at createWorkflow (../../node_modules/nx/src/adapter/ngcli-adapter.js:165:26)
      at ../../node_modules/nx/src/adapter/ngcli-adapter.js:697:26
      at serviceGenerator (src/generators/service/generator.ts:20:3)
      at Object.<anonymous> (src/generators/service/generator.spec.ts:34:5)

but on CI I get the same as OP.

from nx.

sonikasharma1403 avatar sonikasharma1403 commented on September 27, 2024

facing the same issue, but only in the TeamCity environment.

from nx.

sonikasharma1403 avatar sonikasharma1403 commented on September 27, 2024

@AgentEnder , any update on this?

from nx.

github-actions avatar github-actions commented on September 27, 2024

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.

from nx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.