nrwl / nx

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

e2e tests fails when rxjs is introduced to project #1884

Closed urosappdev closed 4 years ago

urosappdev commented 4 years ago

Expected Behavior

Running e2e tests should open cypress.

Current Behavior

Fails with: You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.

Failure Information (for bugs)

I suspect that it is due to some internal configuration of how cypress is being incorporated. I only have dependencies installed I don't use them and e2e tests won't run.

Steps to Reproduce

git clone git@github.com:urosappdev/nx-js-bug.git

  1. nx run e2e booking-e2e

Context

package.json

{
  "name": "tp",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "nx": "nx",
    "start": "nx serve",
    "build": "nx build",
    "test": "nx test",
    "lint": "nx workspace-lint && nx lint",
    "e2e": "nx e2e",
    "affected:apps": "nx affected:apps",
    "affected:libs": "nx affected:libs",
    "affected:build": "nx affected:build",
    "affected:e2e": "nx affected:e2e",
    "affected:test": "nx affected:test",
    "affected:lint": "nx affected:lint",
    "affected:dep-graph": "nx affected:dep-graph",
    "affected": "nx affected",
    "format": "nx format:write",
    "format:write": "nx format:write",
    "format:check": "nx format:check",
    "workspace-schematic": "nx workspace-schematic",
    "dep-graph": "nx dep-graph",
    "help": "nx help"
  },
  "private": true,
  "dependencies": {
    "@nestjs/common": "^6.2.4",
    "@nestjs/core": "^6.2.4",
    "@nestjs/platform-express": "^6.2.4",
    "document-register-element": "1.13.1",
    "react": "16.9.0",
    "react-dom": "16.9.0",
    "react-router-dom": "5.0.1",
    "reflect-metadata": "^0.1.12",
    "rxfire": "^3.8.2",
    "rxjs": "^6.5.3",
    "styled-components": "4.3.2"
  },
  "devDependencies": {
    "@babel/preset-react": "7.0.0",
    "@nestjs/schematics": "^6.3.0",
    "@nestjs/testing": "^6.2.4",
    "@nrwl/cypress": "8.5.1",
    "@nrwl/eslint-plugin-nx": "8.5.1",
    "@nrwl/jest": "8.5.1",
    "@nrwl/nest": "^8.5.1",
    "@nrwl/node": "8.5.1",
    "@nrwl/react": "^8.5.1",
    "@nrwl/web": "8.5.1",
    "@nrwl/workspace": "8.5.1",
    "@testing-library/react": "8.0.5",
    "@types/jest": "24.0.9",
    "@types/node": "~8.9.4",
    "@types/react": "16.9.1",
    "@types/react-dom": "16.8.5",
    "@types/react-router-dom": "4.3.5",
    "@types/styled-components": "4.1.18",
    "@typescript-eslint/eslint-plugin": "2.0.0-alpha.4",
    "@typescript-eslint/parser": "2.0.0-alpha.4",
    "cypress": "3.4.1",
    "dotenv": "6.2.0",
    "eslint": "6.1.0",
    "eslint-config-prettier": "6.0.0",
    "eslint-plugin-import": "2.18.2",
    "eslint-plugin-jsx-a11y": "6.2.3",
    "eslint-plugin-react": "7.14.3",
    "eslint-plugin-react-hooks": "1.6.1",
    "jest": "24.1.0",
    "prettier": "1.18.2",
    "ts-jest": "24.0.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.4.5"
  }
}

Please provide any relevant information about your setup:

 "rxfire": "^3.8.2",
 "rxjs": "^6.5.3",

Running e2e tests fails.

higgins1b commented 4 years ago

I am seeing this same error when trying to finish step 2 in the tutorials. I tried the web and the react tutorials with the same results.

Steps to reproduce

Follow tutorial exactly - https://nx.dev/web/tutorial/01-create-application

    npx create-nx-workspace@latest myorg
    npm install -g @nrwl/cli - **recommended by terminal**
    npm install --save-dev @nrwl/web
    nx g @nrwl/web:application todos
    nx serve todos - **Works correctly**
    Stop development server
    nx e2e todos-e2e --watch - **Error**

Error

01:45:09 ~\Documents\cc\code\myorg [master +4 ~4 -0 !]> nx e2e todos-e2e --watch
**
Web Development Server is listening at http://localhost:4200
**
C:\Users\michaelhiggins\Documents\cc\code\myorg\node_modules\rxjs\internal\util\hostReportError.js:4
    setTimeout(function () { throw err; }, 0);
                             ^

TypeError: You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.
    at Object.exports.subscribeTo (C:\Users\michaelhiggins\Documents\cc\code\myorg\node_modules\rxjs\internal\util\subscribeTo.js:29:15)
    at Object.subscribeToResult (C:\Users\michaelhiggins\Documents\cc\code\myorg\node_modules\rxjs\internal\util\subscribeToResult.js:14:26)
    at SwitchMapSubscriber._innerSub (C:\Users\michaelhiggins\Documents\cc\code\myorg\node_modules\rxjs\internal\operators\switchMap.js:65:54)
    at SwitchMapSubscriber._next (C:\Users\michaelhiggins\Documents\cc\code\myorg\node_modules\rxjs\internal\operators\switchMap.js:55:14)
    at SwitchMapSubscriber.Subscriber.next (C:\Users\michaelhiggins\Documents\cc\code\myorg\node_modules\rxjs\internal\Subscriber.js:66:18)
    at MapSubscriber._next (C:\Users\michaelhiggins\Documents\cc\code\myorg\node_modules\rxjs\internal\operators\map.js:55:26)
    at MapSubscriber.Subscriber.next (C:\Users\michaelhiggins\Documents\cc\code\myorg\node_modules\rxjs\internal\Subscriber.js:66:18)
    at MapSubscriber._next (C:\Users\michaelhiggins\Documents\cc\code\myorg\node_modules\rxjs\internal\operators\map.js:55:26)
    at MapSubscriber.Subscriber.next (C:\Users\michaelhiggins\Documents\cc\code\myorg\node_modules\rxjs\internal\Subscriber.js:66:18)
    at Object.complete (C:\Users\michaelhiggins\Documents\cc\code\myorg\node_modules\rxjs\internal\observable\forkJoin.js:57:40)
    at Object.wrappedComplete (C:\Users\michaelhiggins\Documents\cc\code\myorg\node_modules\rxjs\internal\Subscriber.js:188:76)
    at SafeSubscriber.__tryOrUnsub (C:\Users\michaelhiggins\Documents\cc\code\myorg\node_modules\rxjs\internal\Subscriber.js:205:16)
    at SafeSubscriber.complete (C:\Users\michaelhiggins\Documents\cc\code\myorg\node_modules\rxjs\internal\Subscriber.js:190:26)
    at Subscriber._complete (C:\Users\michaelhiggins\Documents\cc\code\myorg\node_modules\rxjs\internal\Subscriber.js:96:26)
    at Subscriber.complete (C:\Users\michaelhiggins\Documents\cc\code\myorg\node_modules\rxjs\internal\Subscriber.js:78:18)
    at C:\Users\michaelhiggins\Documents\cc\code\myorg\node_modules\rxjs\internal\util\subscribeToPromise.js:8:24

package.json

{
  "name": "myorg",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "nx": "nx",
    "start": "nx serve",
    "build": "nx build",
    "test": "nx test",
    "lint": "nx workspace-lint && nx lint",
    "e2e": "nx e2e",
    "affected:apps": "nx affected:apps",
    "affected:libs": "nx affected:libs",
    "affected:build": "nx affected:build",
    "affected:e2e": "nx affected:e2e",
    "affected:test": "nx affected:test",
    "affected:lint": "nx affected:lint",
    "affected:dep-graph": "nx affected:dep-graph",
    "affected": "nx affected",
    "format": "nx format:write",
    "format:write": "nx format:write",
    "format:check": "nx format:check",
    "workspace-schematic": "nx workspace-schematic",
    "dep-graph": "nx dep-graph",
    "help": "nx help"
  },
  "private": true,
  "dependencies": {
    "document-register-element": "1.13.1"
  },
  "devDependencies": {
    "@nrwl/web": "^8.5.2",
    "@nrwl/workspace": "8.5.2",
    "@types/node": "~8.9.4",
    "dotenv": "6.2.0",
    "eslint": "6.1.0",
    "prettier": "1.18.2",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.4.5",
    "@nrwl/jest": "8.5.2",
    "jest": "24.1.0",
    "@types/jest": "24.0.9",
    "ts-jest": "24.0.0",
    "cypress": "3.4.1",
    "@nrwl/cypress": "8.5.2",
    "@nrwl/eslint-plugin-nx": "8.5.2",
    "@typescript-eslint/parser": "2.0.0-alpha.4",
    "@typescript-eslint/eslint-plugin": "2.0.0-alpha.4",
    "eslint-config-prettier": "6.0.0"
  }
}

Please provide any relevant information about your setup:

Please let me know if I can provide further info.

vsavkin commented 4 years ago

@urosappdev the issue is due to multiple version of rxjs in your node modules. RxJs Observable can fail in this case because an observable created by one copy of rxjs is consumed.

You can add the following to your package.json:

  "resolutions": {
    "rxjs": "6.5.3",
    "rxjs-compat": "6.5.3"
  }

This should fix it.

@higgins1b unfortunately I'm not able to repro it. Can you push a repo with the repro?

urosappdev commented 4 years ago

Yeah resolutions do work.

trumbitta commented 4 years ago

Update: it worked once I found out resolutions is a yarn thing and I used yarn install.

@vsavkin The resolutions fix doesn't work for me. I thought the culprit was redux-observable (the only RxJS related dependency I can think of), but the error still shows up if I remove it then rm -rf node_modules package-lock.json && npm i && npm run affected:e2e.

Full deps:

  "dependencies": {
    "@nestjs/common": "^6.10.1",
    "@nestjs/core": "^6.10.1",
    "@nestjs/platform-express": "^6.10.1",
    "@nestjs/typeorm": "^6.2.0",
    "document-register-element": "1.13.1",
    "formik": "^2.0.4",
    "react": "16.10.2",
    "react-dom": "16.10.2",
    "react-redux": "^7.1.3",
    "react-router-dom": "^5.1.2",
    "redux-devtools-extension": "^2.13.8",
    "redux-observable": "^1.2.0",
    "redux-persist": "^6.0.0",
    "redux-starter-kit": "^1.0.1",
    "reflect-metadata": "^0.1.13",
    "rxjs": "^6.5.3",
    "sqlite3": "^4.1.0",
    "styled-components": "4.4.0",
    "typeorm": "^0.2.20"
  },
  "devDependencies": {
    "@babel/preset-react": "7.0.0",
    "@nestjs/schematics": "^6.7.3",
    "@nestjs/testing": "^6.10.1",
    "@nrwl/cli": "^8.7.1",
    "@nrwl/cypress": "8.7.1",
    "@nrwl/eslint-plugin-nx": "8.7.1",
    "@nrwl/jest": "8.7.1",
    "@nrwl/nest": "^8.7.1",
    "@nrwl/node": "8.7.1",
    "@nrwl/react": "8.7.1",
    "@nrwl/web": "8.7.1",
    "@nrwl/workspace": "8.7.1",
    "@testing-library/react": "9.3.0",
    "@types/jest": "24.0.9",
    "@types/node": "~8.9.4",
    "@types/react": "16.9.6",
    "@types/react-dom": "16.9.2",
    "@types/react-redux": "^7.1.5",
    "@types/react-router-dom": "^5.1.2",
    "@types/styled-components": "4.1.19",
    "@typescript-eslint/eslint-plugin": "2.3.2",
    "@typescript-eslint/parser": "2.3.2",
    "commitizen": "^4.0.3",
    "cypress": "3.4.1",
    "cz-conventional-changelog": "^3.0.2",
    "dotenv": "6.2.0",
    "eslint": "6.1.0",
    "eslint-config-prettier": "6.0.0",
    "eslint-plugin-import": "2.18.2",
    "eslint-plugin-jsx-a11y": "6.2.3",
    "eslint-plugin-react": "7.16.0",
    "eslint-plugin-react-hooks": "2.1.2",
    "jest": "24.1.0",
    "prettier": "1.18.2",
    "rollup": "^1.27.2",
    "ts-jest": "24.0.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.4.5"
  },
  "resolutions": {
    "rxjs": "6.5.3",
    "rxjs-compat": "6.5.3"
  },
vsavkin commented 4 years ago

I have an update.

Talked to Ben Lesh and apparently the following fixes it: https://github.com/nrwl/nx/commit/a88ee635781e919779a0bad6ad43e97aa37a3d16

I'll cut a release today with the fix.

I'm going to close this issue.

github-actions[bot] commented 1 year 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.