How to use Protractor with Angular 2? - javascript

I use Protractor with Angular 1.x. I would like to migrate to Angular 2.0 step by step but I don't see Protractor in the docs.
Has protractor been dropped since Angular 2? Should I write my tests without using Protractor, using Jasmine instead (or others)?

You can test Angular 2 applications with Protractor (starting from Protractor 2.5.0).
For Protractor 5.0.0+, you don't have to do anything specific, Protractor will auto-detect the Angular version used in the application under test.
For Protractor >= 2.5.0 and <= 4.0.14, you would only need to add useAllAngular2AppRoots: true to your config. Here is a sample.
Note that several built-in Protractor matchers would not yet work with Angular2, see:
Protractor Angular 2 Failed: unknown error: angular is not defined
There is also that Protractor+Angular2 problem in Firefox (still unresolved), see:
Can't run Selenium via Protractor on Firefox after update to Angular 2

Related

How to unit test Capacitor project?

I have some JavaScript unit tests that I need to run. We use a combination of mocha and chai for the tests. We are looking into possibly switching to Capacitor as a tool to convert web apps to mobile and electron projects. In order to get Capacitor working in our unit tests we have to run the tests using jsdom as Capacitor makes use of the window object. Now the unit tests are run through jsdom these parts of Capacitor are happy and our tests pass.
However we have one module that will require the use of Capacitor's Filesystem API. Filesystem has no web implementation so these tests now fail as we are using jsdom. The log states Filesystem does not have web implementation.. Is there any way I can get a combination of having window available in our unit tests while also allowing the use of Filesystem?
I was able to fix this. I used jsdom from the terminal and it didn't work. However using the JavaScript API I was able to get that test to pass.

How to test Angular 6 with jest and cucumber?

I have been trying to test an Angular 6 application with Jest and cucumber.
I currently using this module with the application https://www.npmjs.com/package/jest-preset-angular but would like to use cucumber js https://github.com/cucumber/cucumber-js with it and use feature files with the tests and have them in steps
Can this be done?
And how would I go about this?
There are several ways of doing it:
protractor: https://www.npmjs.com/package/protractor-cucumber-framework (Medium)
cypress: https://www.npmjs.com/package/cypress-cucumber-preprocessor (Medium)
jest: https://www.npmjs.com/package/jest-cucumber
Protractor is kind of old so I would go with cypress. Jest is an alternative to Jasmine, it is faster (some comparison).

How to run Angular-scenario runner tests with Angular1/2 hybrid app?

We have a big Angular 1.4 application. Our equally big set of E2E tests are written using Angular Scenario Runner (Yes, I know we should have used Protractor).
Now, we are trying to transition to Angular2, going through the ngUpgrade hybrid approach.
The issue is that the ngScenario tests are all failing due to bootstrapping issues. As, the bootstrapping is asynchronous for the upgradeAdapter, opposed to synchronous in Angular 1.
Please help as to what could be done ?

Does Protractor come with Jasmine 2.x yet?

I was reviewing Protractor website and saw this paragraph mention that Protractor development is in the process of upgrading to Jasmien 2.0.
Currently, Jasmine Versions 1.3 and 2.0 are supported. Jasmine 1.3 is the default test framework and is available for use when you install Protractor. However, we're in the process of upgrading to Jasmine 2.0, and will deprecate support for 1.3 in the future.
After digging further into GitHub documentation, it looks like Jasmine 2.0 is already supported. Does their website need to be revised?
This documentation page can probably be improved to avoid confusion. Most importantly, it points out that nowadays (since protractor 1.6.0), both jasmine 1.x and jasmine 2.x are supported and you can choose which one to use.
There is a specific setting that controls the behavior:
framework: "jasmine" // or "jasmine2" for jasmine 2.x

Jasmine test runner integration with visual studio and a build process

how do you integrate Jasmine's test runner with Visual Studio and your custom build process ? I've read an article at codebetter that shows how to achieve this task using FubuMVC and a few other components but I was wondering if you can recommend any alternatives ?
So how do you do that at your workplace ?
Many thanks,
Tomek
Take a look at Chutzpah (http://chutzpah.codeplex.com/). It has integrated test runners and command line options for running Jasmine or QUnit tests. Behind the scenes it uses PhantomJS, a headless browser, to load up tests and run them.
I know this is a year old, but FYI, I noticed that a new AngularJS SPA Template project (ASP.NET) in Visual Studio 2013 includes Jasmine (SpecRunner.cshtml). The AngularJS SPA Template is an extension to VS2013 (and can be installed on VS2012 and VS2010).
So it is there now, go to extensions and updates in VS to find it!

Categories

Resources