Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

test(e2e/dart): add support for Dart e2e testing #1369

Closed
wants to merge 1 commit into from

Conversation

chalin
Copy link
Contributor

@chalin chalin commented May 12, 2016

Adapted the gulp run-e2e-tests task to process --lang=dart.

This task runs the same e2e test suites as for TS, since the example apps should behave the same in TS and Dart. For now, only

  • quickstart
  • toh (toh-5)

tests are enabled. ALL tests are passing!
Contributing to #1521, #1619.

@wardbell
Copy link
Contributor

The code looks good ... but I can't tell that it is actually running or if it succeeded because it doesn't update our protractor-results.txt file ... of if it does I don't see where.

The runE2eTestsForDart is almost identical to runE2eTests. Let's refactor so that we keep this code DRY. Is that something you can do or should I?

@chalin
Copy link
Contributor Author

chalin commented May 12, 2016

It runs nicely :) ... below is an excerpt of the output showing how ts pipes passes but it fails for Dart (because my PR on Dart pipes hasn't landed yet). It updates protractor-results.txt just like the TS test task does.

[09:46:42] running: npm run http-server:e2e -- -s
[09:46:42] running: npm run tsc
[09:46:43] 
> angular2-examples-master@1.0.0 http-server:e2e /Users/chalin/git/angular.io/public/docs/_examples/pipes/ts
> http-server "-s"

[09:46:43] 
> angular2-examples-master@1.0.0 tsc /Users/chalin/git/angular.io/public/docs/_examples/pipes/ts
> tsc

[09:46:46] completed: npm run tsc
[09:46:46] running: protractor /Users/chalin/git/angular.io/public/docs/_examples/pipes/protractor.config.js --params.appDir=public/docs/_examples/pipes/ts --params.outputFile=/Users/chalin/git/angular.io/protractor-results.txt
[09:46:46] [09:46:46] I/direct - Using ChromeDriver directly...
[09:46:46] [09:46:46] I/launcher - Running 1 instances of WebDriver
[09:46:47] AppDir: public/docs/_examples/pipes/ts
[09:46:47]   Suite: Pipes
[09:46:52]     passed - should open correctly
[09:46:52]     passed - should show 4 heroes
[09:46:52]     passed - should show a familiar hero in json
[09:46:52]     passed - should show alternate birthday formats
[09:46:53]     passed - should be able to toggle birthday formats
[09:46:53]     passed - should be able to chain and compose pipes
[09:46:53]     passed - should be able to use ExponentialStrengthPipe pipe
[09:46:53]     passed - should be able to use the exponential calculator
[09:46:54]     passed - should support flying heroes (pure) 
[09:46:55]     passed - should support flying heroes (impure) 
[09:46:55]     passed - should show an async hero message
[09:46:55]   Suite passed: Pipes
[09:46:55] [09:46:55] I/launcher - 0 instance(s) of WebDriver still running
[09:46:55] [09:46:55] I/launcher - chrome #01 passed
[09:46:55] completed: protractor /Users/chalin/git/angular.io/public/docs/_examples/pipes/protractor.config.js --params.appDir=public/docs/_examples/pipes/ts --params.outputFile=/Users/chalin/git/angular.io/protractor-results.txt
[09:46:55] Suites passed:
[09:46:55]   public/docs/_examples/pipes/ts
[09:46:55] All tests passed
[09:46:55] Elapsed time: 31.159 seconds
[09:46:55] Finished 'run-e2e-tests' after 56 s
[09:46:55] completed: npm run http-server:e2e -- -s

@chalin
Copy link
Contributor Author

chalin commented May 12, 2016

I'll DRY it up now and push a delta.

@chalin chalin force-pushed the chalin-dart-e2e-0512 branch from d3e96e3 to d1d5adc Compare May 12, 2016 20:55
@chalin
Copy link
Contributor Author

chalin commented May 12, 2016

All DRY'd up! (And I ensured that it still works over TS and Dart tests.)

@wardbell
Copy link
Contributor

Hi Patrice. So I tried again. I like the refactor. But I don't see any evidence that Dart apps are being tested.

I don't actually know what it takes to run Dart or whether it is possible on my machine. I just ran gulp run-e2e-tests --filter=pipe which runs only the pipe app tests. The only version tested was the TS version. How do we explain that?

I ran for QuickStart and it only ran for TS (it used to run for both TS and JS); same for forms.

I reverted to master and am able to test both TS and JS apps again.

I want to merge it. But I'd like some explanation from you first about why I experience something different ... and why I am no longer able to test JS

@chalin
Copy link
Contributor Author

chalin commented May 13, 2016

To run the Dart tests you need to include the --lang=dart flag, e.g.:

run-e2e-tests --filter=pipe --lang=dart

Without that flag it runs the test like it did before (I didn't want to change the default behavior).

Of course, to be able to build the app (and transpiles it JS so that it runs in Chrome), you'll need to have:

  • Dart SDK installed with the
  • Dart bin in your path.

@chalin
Copy link
Contributor Author

chalin commented May 13, 2016

Oh, I just realized that the sample output I provided showed test being run from both TS and Dart (I fixed that now). Sorry, about that, it must have been from a run before I reverted to the behavior I mentioned above (i.e., run-e2e-tests without arguments still only runs just the tests it did before).

@chalin chalin force-pushed the chalin-dart-e2e-0512 branch 5 times, most recently from b1b057d to a9e9a40 Compare May 15, 2016 22:07
@wardbell
Copy link
Contributor

wardbell commented May 16, 2016

Hmm. I wasn't counting on installing Dart on my machine. I run Windows. Is it possible on Windows?

FWIW, I'm ok with accepting this PR on your say-so, having established that it does no harm to the TS/JS tests. But it would be a great thing if we routinely ran the tests over TS/JS/Dart as part of our routine practice. So I'd be game to install Dart if it is possible.

@chalin
Copy link
Contributor Author

chalin commented May 17, 2016

I'm ok with accepting this PR on your say-so,

Great!

having established that it does no harm to the TS/JS tests.

I believe that there is no impact on the TS/JS tests. (FYI, part of my motivation for the original non-DRY version of this change was to make it really obvious that there was no impact on the TS/JS side.)

great thing if we routinely ran the tests over TS/JS/Dart as part of our routine practice

I agree. In fact, I think that we should get the docs under Travis CI! Then we could ensure that for every submitted PR all tests pass.

I'd be game to install Dart

Here are the Windows installation instructions.

@wardbell
Copy link
Contributor

Installed with cholatey as instructed and tried gulp run-e2e-tests --filter=pipe --lang=dart.

It tried to do that Dart test but failed with

[22:02:59] running: npm run http-server:e2e -- C:/github/angular.io/public/docs/_examples/pipes/dart/build/web -s
[22:02:59] running: pub upgrade
[22:02:59] 'pub' is not recognized as an internal or external command,
operable program or batch file.

[22:02:59] completed with error:pub upgrade

at which point it doesn't actually run the Dart test ... or at least there is no output in protractor-results.txt.

Console reports a failed test suite.

Maybe you can VC with me and we can power through it? I'm eager to accept this.

@Foxandxss
Copy link
Member

I just installed all the dart stuff on my machine (OSX), made several tests on this and works like a charm.

Awesome work @chalin

@wardbell
Copy link
Contributor

@Foxandxss No problem with pub? I wonder what I'm doing wrong?

@Foxandxss
Copy link
Member

Different OS so your mileage may vary.

It works perfect for me

This task runs the *same e2e test suites as for TS*, since the example
apps should behave the same in TS and Dart. For now, only

- quickstart
- toh (toh-5)

tests are enabled. ALL Dart tests are passing!
@chalin chalin force-pushed the chalin-dart-e2e-0512 branch from a9e9a40 to f4a47f7 Compare May 17, 2016 15:21
@chalin
Copy link
Contributor Author

chalin commented May 17, 2016

@Foxandxss: thanks for confirming that it works for you too!
@wardbell: now that Jesus has confirmed that it works for him, could you merge this in? I suggest that we work through your environment setup issues separately (for which I would be glad to help).

Btw, have you updated PATH to include the path to the Dart executables? Assuming that chocolatey has its own bin directory, I think that you need to execute a command similar to what is given on the Chocolatey home page:

SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin

@wardbell
Copy link
Contributor

wardbell commented May 17, 2016

The SET PATH was it! Must have overlooked. Thanks!

I made a couple of small changes:

  1. The default (no --lang) option only ran TS tests, not both JS and TS tests as it did previously. Now it runs both.
  2. Added the --lang=all option which runs TS, JS, and Dart tests.

Tested it and it works.

Thanks!

@wardbell wardbell closed this in 6751f77 May 17, 2016
@chalin
Copy link
Contributor Author

chalin commented May 17, 2016

Great! We're one step closer to being ready for Travis CI (for all 3 languages)!

@chalin chalin deleted the chalin-dart-e2e-0512 branch May 17, 2016 17:50
@chalin
Copy link
Contributor Author

chalin commented May 17, 2016

Btw, good catch for the js tests. Thanks.
And good improvement: to add "all".

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants