I am afraid someone close my question but I couldn't find a satisfying question (maybe because I am very limited in Angular 2+ world and I understood something wrong).
As far as I could understand after few Hello World done and few YouTube demo watched:
ng test:
- you write your test using Jasmine language
- you test your test with many Browsers available using Karma
- you execute either unit or integrated testing
- all
xxx.compnent.spec.ts
run and a final report similar to JUnit is showed in browser
ng e2e:
- you write your test using Jasmine language
- you test your test with many Browsers available using Karma
you write your tests with nesting user event in mind
eg. page.navigateTo(); page.getParagraphText() .then(msg => expect(msg).toEqual('Welcome to app!!')) .then(msg => expect(msg).toEqual('xxx')) .then(done, done.fail);
you execute End to End test using protractor mainly after deployed the application a kind of pre-production environment
- the tests under e2e folder are triggered and the result is printed in command line console
Theoracly saying, the second is specific for end to end where the focus is to simulate a entire flow done by an end user.
Hopefully, until here is correct, I am wondering what is happening behind the scene that really make them different. I don't want to compare which is better but certainly I am missing some point somehow because I created few tests using exact same idea done by end user and I triggered it by ng test.
For instance:
...
it('should display the modal when `create Paste` is clicked', () => {
let createPasteButton = fixture.debugElement.query(By.css("button"));
//create a spy on the createPaste method
spyOn(component,"createPaste").and.callThrough();
//triggerEventHandler simulates a click event on the button object
createPasteButton.triggerEventHandler('click',null);
//spy checks whether the method was called
expect(component.createPaste).toHaveBeenCalled();
fixture.detectChanges();
expect(component.showModal).toBeTruthy("showModal should now be true");
expect(element.innerHTML).toContain("source-modal");
});
...
I remenbered I read something like "protractor offer a waiting/sleeping behaviour during tests execution" but I can't see where this aggregate value when I see the tests done without protractor been able to simulate a final user as well. As long as you code your tests to do exact same flow done by an end user it will be same e2e test propose under e2e folder created by Angular Cli.
If my study drove me to correctly understanding as posted above then, the only real difference is the way I, as developer, is organizing my tests. There is nothing really different happening behind the scene.
Again, I would appreciate see this as clarifing question for didatic purpose: there is no intention to compare frameworks here at all.