Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e test in latest wepack version not working #1981

Closed
stefanaerts opened this issue Sep 5, 2016 · 14 comments
Closed

e2e test in latest wepack version not working #1981

stefanaerts opened this issue Sep 5, 2016 · 14 comments

Comments

@stefanaerts
Copy link

Please provide us with the following information:

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
    OSX El Capitan

  2. Versions. Please run ng --version. If there's nothing outputted, please run
    in a Terminal: node --version and paste the result here:
    angular-cli: 1.0.0-beta.11-webpack.8
    node: 6.5.0
    os: darwin x64

  3. Repro steps. Was this an app that wasn't created using the CLI? What change did you
    do on your code? etc.
    created default app and added typescript to the package.json and changed the rxjs version to 5.0.0-beta.06 instead 11

  4. The log given by the failure. Normally this include a stack trace and some
    more information.
    my package.json:
    "name": "temp-app",
    "version": "0.0.0",
    "license": "MIT",
    "angular-cli": {},
    "scripts": {
    "start": "ng serve",
    "lint": "tslint "src/*/.ts"",
    "test": "ng test",
    "pree2e": "webdriver-manager update",
    "e2e": "protractor"
    },
    "private": true,
    "dependencies": {
    "@angular/common": "2.0.0-rc.5",
    "@angular/compiler": "2.0.0-rc.5",
    "@angular/core": "2.0.0-rc.5",
    "@angular/forms": "0.3.0",
    "@angular/http": "2.0.0-rc.5",
    "@angular/platform-browser": "2.0.0-rc.5",
    "@angular/platform-browser-dynamic": "2.0.0-rc.5",
    "@angular/router": "3.0.0-rc.1",
    "core-js": "^2.4.0",
    "rxjs": "5.0.0-beta.06",
    "ts-helpers": "^1.1.1",
    "zone.js": "0.6.12",
    "typescript": "2.0.0"
    },
    "devDependencies": {
    "@types/jasmine": "^2.2.30",
    "angular-cli": "1.0.0-beta.11-webpack.8",
    "codelyzer": "~0.0.26",
    "jasmine-core": "2.4.1",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "0.13.22",
    "karma-chrome-launcher": "0.2.3",
    "karma-jasmine": "0.3.8",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "4.0.3",
    "ts-node": "1.2.1",
    "tslint": "3.13.0",
    "typescript": "2.0.0"
    }
    }

  5. Mention any other details that might be useful.
    ng test works,
    ng e2e not, i see in a flits the word "data;" in the browser url bar before it closes.


    Thanks! We'll be in touch soon.

@stefanaerts
Copy link
Author

ng e2e gives always succeeded even if you change the test to "api works" for example

@evanrooijen
Copy link

+1

@duncanhunter
Copy link

I temporarily fixed this issues by rolling back the version of protractor to 3.3.0.

Possibly related to this issue angular/protractor#3511

@stefanaerts
Copy link
Author

stefanaerts commented Sep 8, 2016

changing it to version 3.3.0 doesnt work with this version of CLI using webpack
image

so in app.po.ts typescript doesn't find 'protractor/globals'
import { browser, element, by } from 'protractor/globals';

@stefanaerts
Copy link
Author

stefanaerts commented Sep 8, 2016

but at least the test failed this way (-) can we make jokes (-)?

@duncanhunter
Copy link

@stefanaerts you are right it does not work with protractor 3.03 on a new cli generated app with 1.0.0-beta.11-webpack.8, but my migrated project to 1.0.0-beta.11-webpack.8 this worked for me.

I did, however, run a quick test on this newly generated app and updated my protractor to protractor 4.0.5 and it worked. First I deleted my node_modules and did a clean npm install and it started failing my tests I wanted to fail.

Not sure why my migrated app is different than a new one?

@stefanaerts
Copy link
Author

what is in your package.json?
Does your app.po.ts does this
import { browser, element, by } from 'protractor/globals';

@duncanhunter
Copy link

duncanhunter commented Sep 8, 2016

Here is a link to a repo I just pushed to, look at initial commits 1 and 2. https://github.com/duncanhunter/ngrx-demo

I took the following steps

  1. Create new cli generated app
    ng new ngrx-demo
  2. Check cli version is 1.0.0-beta.11-webpack.8
    ng -v
  3. Delete node_modeules
    rm -rf node_modules
  4. Update protractor in package.json
    "protractor": "4.0.5"
  5. npm install
    npm i
  6. Change app.e2e-spec.ts to fail not pass
    `expect(page.getParagraphText()).toEqual('app work!');``
  7. Start the app
    ng serve
  8. Run the e2e tests
    ng e2e

@stefanaerts
Copy link
Author

it works for me also now, but not like that.
i did several things,maybe some of them do not matter,but i give them all:
updates to package.json:

  1. removed angular/compiler-cli
  2. add "@angular/platform-server": "2.0.0-rc.5",
  3. add "@types/webpack": "^1.12.33",
  4. add "reflect-metadata": "0.1.8",
  5. changed "karma-remap-istanbul": "0.2.1" back to "karma-remap-istanbul": "^0.2.1",
  6. add "protractor": "4.0.5",

my types dependencies contain now
image

i changed typings.d.ts to this picture because of errors in console when i run ng serve or build:
image

now both test options work, ng test and ng e2e work like they should work.
i changed one line in typings.d.ts back for require to be of type any because test.ts "require.context" complained "context" does not exist on NodeRequire.

image

now everything still works but I only get an error in the console when i run ng test:

ERROR in [default] /Users/stefanaerts/tmp/testcliwebpack/src/typings.d.ts:7:12
Subsequent variable declarations must have the same type. Variable 'require' must be of type 'NodeRequire', but here has type 'any'.

BUT the tests work, so for me this can be closed

@stefanaerts
Copy link
Author

stefanaerts commented Sep 8, 2016

@Brocco
Mike maybe an enhancement for the CLI.

Well i changed it better:
image

and did a cast in the test.ts:
image

i added more tests to components in separated directories and and test.ts found them all, so the script works fine this way.

@ghost
Copy link

ghost commented Sep 9, 2016

Here's some background: angular/protractor#3505

@stefanaerts
Copy link
Author

please read christian, its solved

@ghost
Copy link

ghost commented Sep 10, 2016

Like I said, I just wanted to give some background regardless of whether it's solved or not.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants