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

[CI] Run tests on more browsers #615

Closed
Reinmar opened this issue Oct 17, 2017 · 8 comments
Closed

[CI] Run tests on more browsers #615

Reinmar opened this issue Oct 17, 2017 · 8 comments
Assignees
Labels
type:task This issue reports a chore (non-production change) and other types of "todos".
Milestone

Comments

@Reinmar
Copy link
Member

Reinmar commented Oct 17, 2017

Right now, using Travis, we run tests on Chrome only. This is great for day-to-day development but we don't control much the status of things on different browsers (Firefox, Safari, Edge and some mobile ones).

This is a problem before releases because we're left with many failing tests and it's really hard to figure out at that point whether to care about those. And once we have some red tests already, it's also hard to see if we're not breaking something more when making changes or implementing new features.

BrowserStack

Therefore, let's try to introduce BrowserStack to our CI. I actually don't know what options does it bring so we need a proper research here. But, let's write down some requirements just to start:

  • We won't have unlimited plans there so we may need to limit what we test with BrowserStack.
    • We need the status of the whole project so master-revisions and master are one thing for sure,
    • But it'd also be great if PRs in other packages were tested too. I don't know what options BrowserStack provides but it'd be ok if PRs were tested in a more on-demand manner. Let's see what options we have.
  • Reporting to Slack is near must-have (so we are aware of the status of things) and badges on GH are a complete must-have :D.

Failing tests

Besides dealing with BrowserStack we need to fix our tests on those browsers. Here, we can identify a couple of issues:

  • Fixing broken code or tests.
  • Dealing with browser's poor stability. At least on my machine, Firefox and Edge often crash when running CKEditor's tests. @pomek had more luck but we don't know how all this will behave on BrowserStack.
  • Fix leaking tests. Many tests don't destroy editors and don't remove appended elements. This may cause the issues described in the previous two points so it's worth fixing them.
@Reinmar Reinmar added status:confirmed type:task This issue reports a chore (non-production change) and other types of "todos". labels Oct 17, 2017
@pomek pomek self-assigned this Oct 27, 2017
@pomek
Copy link
Member

pomek commented Oct 30, 2017

I'm testing the BrowserStack from the Friday and I have to say – I'm soooooo excited!

This tool really allows testing our project on different browsers.

All important things I described below. There is nothing to say more except the one thing – bootstrap time (everything that is done before starting tests execution) is not counted to "BrowserStack automate testing" time.

Integration with existing project

Because we use Karma, there is no additional stuff to do.

The one thing to do is install karma-browserstack-launcher.

Available browsers

In order to see all available browser, please follow this instruction – https://www.browserstack.com/automate/rest-api#rest-api-browsers.

There are 1193 available browsers which we can use to tests.

node -e "console.log( require( './browser.json' ).length );"
1193

I chose 4 browsers on different operation systems:

  1. Edge 16 (Windows 10),
  2. Chrome 62 (OS X Mavericks),
  3. Firefox 56 (OS X Yosemite),
  4. Safari 11 (OS X High Sierra).

Execute tests on CI

It will work because CI uses the same code which we use.

I created an example repository with an integration with Travis and BrowserStack.

See the latest build: https://travis-ci.org/pomek/browserstack-test/builds/293608963.

How to run it on my local machine?

  • You need to have our dev repository on the same level what the main repository:
$ tree -L 1
── ckeditor5
└── ckeditor5-dev

If you don't have ckeditor5-dev repository:

git clone -b t/ckeditor5/615 [email protected]:ckeditor/ckeditor5-dev.git
cd ckeditor5-dev
lerna bootstrap

If you have the repository already cloned, just check out the branch to t/ckeditor5/615:

# git fetch
git checkout t/ckeditor5/615
lerna bootstrap # or `npm i` from `ckeditor5-dev-tests`
  • Go to the main repository (ckeditor5) and call the script below:
./scripts/switch-to-dev-dev.sh

It will link dependencies from the ckeditor5-dev repository. Packages @ckeditor/ckeditor5-dev* will be read from the local repository instead of npm.

  • Now you are able to use BrowserStack. You need to specify the --username and --access-key options for gulp test command:
gulp test --username=BS_USERNAME --access-key=BS_ACCESSKEY --files=autoformat
# or using aliases
gulp test -u BS_USERNAME -a BS_ACCESSKEY -f autoformat

An access token is specified Account > Settings:

image

Plan for the future

@Reinmar, I'm waiting for your feedback, so feel free to add it :D

I didn't execute all tests using BS so it will be the thing to do. I will prepare a report which shows how many tests fails on other browsers.

Then we will see what do to next.

Screenshots

Not too many but few are always better than nothing.

gulp test -u ... -a ... -f autoformat -c

image

Every browser contains a video record:

image

Coverage reports are generated for each browser:

image

@pomek
Copy link
Member

pomek commented Oct 31, 2017

I've just prepared the report which shows how many tests fail.

Test command:

gulp test -u ... -a ... -f [Package / Scope]

Legend: Executed Tests / All tests (X FAILED).

If I had any problem with the package, I reported an issue in proper repository. A link to the issue is added in the last cell in a row.

The table below does not contain ckeditor5-engine package. Engine is described below the table because there is no easy way to execute all tests on Edge.

Package / Browser Firefox Edge Chrome Safari
Adapter-CKFinder 18 / 18 18 / 18 18 / 18 18 / 18
Autoformat 44 / 44 44 / 44 44 / 44 44 / 44
Basic-styles 76 / 76 76 / 76 76 / 76 76 / 76
Block-quote 56 / 56 56 / 56 56 / 56 56 / 56
Clipboard 62 / 62 62 / 62 62 / 62 62 / 62
Core 143 / 143
1 FAILED
143 / 143 143 / 143 143 / 143
~1 FAILED~~
Issue
Easy-image 9 / 9 9 / 9 9 / 9 9 / 9
Editor-balloon 30 / 30 30 / 30 30 / 30 30 / 30
Editor-classic 43 / 43 43 / 43 43 / 43 43 / 43
Editor-inline 59 / 59 59 / 59 59 / 59 59 / 59
Enter 25 / 25 25 / 25 25 / 25 25 / 25
Essentials 2 / 2 2 / 2 2 / 2 2 / 2
Heading 68 / 68 68 / 68 68 / 68 68 / 68
Image 219 / 219
2 FAILED
219 / 219
2 FAILED
219 / 219 219 / 219 Issue
Link 130 / 130 129 / 130
1 FAILED
130 / 130 130 / 130 Issue
List 373 / 379 373 / 379 373 / 379 373 / 379
Markdown-gfm 192 / 192 192 / 192 192 / 192 192 / 192
1 FAILED
Issue
Paragraph 69 / 69 69 / 69 69 / 69 69 / 69
Typing 147 / 147 147 / 147
1 FAILED
147 / 147 147 / 147 Issue
UI 556 / 556 556 / 556
1 FAILED
556 / 556 556 / 556
16 FAILED
Issue
Undo 67 / 67 67 / 67 67 / 67 67 / 67
Upload 100 / 100 100 / 100 100 / 100 100 / 100
Utils 574 / 574 574 / 574
1 FAILED
574 / 574 574 / 574
1 FAILED
Issue
Widget 139 / 139 139 / 139 139 / 139 139 / 139

ckeditor5-engine

As I mentioned above, we aren't able to execute all tests on Edge. I decided to execute tests separately:

Scope / Browser Firefox Edge Chrome Safari
engine/controller/*.js 311 / 311 311 / 311
1 FAILED
311 / 311 311 / 311
engine/conversion/*.js 392 / 392 392 / 392 392 / 392 392 / 392
engine/dataprocessor/*.js 34 / 34 34 / 34 34 / 34 34 / 34
engine/dev-utils/*.js 192 / 192 192 / 192 192 / 192 192 / 192
engine/model/**/*.js 1535 / 1535 1535 / 1535 1535 / 1535 1535 / 1535
engine/view/**/*.js 761 / 1250
11 FAILED
1252 / 1252
1 FAILED
1250 / 1250
4 FAILED
933 / 1250
23 FAILED

Dedicated issue: https://github.com/ckeditor/ckeditor5-engine/issues/1177.

@pomek
Copy link
Member

pomek commented Nov 6, 2017

I executed the passed tests once again. Unfortunately, Edge does not want to work :(

List of the tests - Edge 16.16299.0 (Windows 10 0.0.0) ClassicEditor constructor() ui creates a single div editable root in the view FAILED - Edge 16.16299.0 (Windows 10 0.0.0) ClassicEditor create() "before each" hook for "creates an instance which inherits from the ClassicEditor" FAILED - Edge 16.16299.0 (Windows 10 0.0.0) ClassicEditor create() "after each" hook for "creates an instance which inherits from the ClassicEditor" FAILED - Edge 16.16299.0 (Windows 10 0.0.0) ClassicEditor create - events fires all events in the right order FAILED - Edge 16.16299.0 (Windows 10 0.0.0) ClassicEditor create - events "after each" hook for "fires all events in the right order" FAILED - Edge 16.16299.0 (Windows 10 0.0.0) ClassicEditor destroy "before each" hook for "sets the data back to the editor element" FAILED - Edge 16.16299.0 (Windows 10 0.0.0) ClassicEditorUI "before each" hook for "sets #editor" FAILED - Edge 16.16299.0 (Windows 10 0.0.0) Spellchecking integration "before all" hook FAILED - Edge 16.16299.0 (Windows 10 0.0.0) Spellchecking integration "after all" hook FAILED - Edge 16.16299.0 (Windows 10 0.0.0) Bug ckeditor5-typing#59 "before each" hook for "editor does not blow up when deleting last styled character" FAILED - Edge 16.16299.0 (Windows 10 0.0.0) Bug ckeditor5-typing#59 "after each" hook for "editor does not blow up when deleting last styled character" FAILED - Edge 16.16299.0 (Windows 10 0.0.0) UndoEngine integration "before each" hook for "add and undo" FAILED - Edge 16.16299.0 (Windows 10 0.0.0) ImageUpload "before each" hook for "should include ImageUploadProgress" FAILED - Edge 16.16299.0 (Windows 10 0.0.0) ImageUpload "after each" hook for "should include ImageUploadProgress" FAILED - Edge 16.16299.0 (Windows 10 0.0.0) ImageUploadButton "before each" hook for "should include ImageUploadEngine" FAILED - Edge 16.16299.0 (Windows 10 0.0.0) ImageUpload "after each" hook for "should include ImageUploadProgress" FAILED - Edge 16.16299.0 (Windows 10 0.0.0) ImageUploadButton "before each" hook for "should include ImageUploadEngine" FAILED - Edge 16.16299.0 (Windows 10 0.0.0) ImageUploadButton "after each" hook for "should include ImageUploadEngine" FAILED - Edge 16.16299.0 (Windows 10 0.0.0): Executed 1291 of 1533 (18 FAILED) (skipped 6) DISCONNECTED (1 min 46.771 secs / 11.632 secs)

Most of these tests fail because: TypeError: Object doesn't support property or method 'Symbol.iterator'.

Safari and Chrome work fine.

@pomek
Copy link
Member

pomek commented Nov 10, 2017

Almost all tests listed above after https://github.com/ckeditor/ckeditor5-ui/issues/337 work. This one still fails: Edge 16.16299.0 (Windows 10 0.0.0) Spellchecking integration "after all" hook FAILED.

@pomek pomek added this to the iteration 13 milestone Nov 10, 2017
@Reinmar Reinmar modified the milestones: iteration 13, iteration 14 Nov 14, 2017
@szymonkups
Copy link
Contributor

szymonkups commented Nov 15, 2017

Other than running automated tests, we can use BrowserStack's live testing.
Enter "Live" tab on a BrowserStack page:

image

(It will ask you to install additional extension to your browser - it will allow to open your local addresses inside started browser).
After selecting the browser, BrowserStack will show you it's instance inside your browser. You can enter local addresses there and run tests inside:

image

You can even put a breakpoint and run debugger in devtools there:

image

NOTE: testing on Firefox and Edge is free, that means it will not drain your free live testing minutes limit.

@pomek
Copy link
Member

pomek commented Nov 17, 2017

Status of things:

  • We have working ckeditor5-engine on all browsers. Thanks to @szymonkups,
  • One test fails on Firefox in ckeditor5-image (missing focus),
  • One test fails on Edge in ckeditor5-link but it will be fixed when T/1179: View stringify utility will sort values in [class] and [style] ckeditor5-engine#1184 will be merged (invalid order of values in [style] attribute),
  • 16 tests fail on Safari in ckeditor5-ui. 2 tests fail on Edge in the same package,
  • One test fails on Safari in ckeditor5-utils (cannot stub properties in an iframe).

@pomek
Copy link
Member

pomek commented Dec 5, 2017

The latest build with changed branches required for BrowserStack – https://travis-ci.org/ckeditor/ckeditor5/builds/311797957.

@pomek
Copy link
Member

pomek commented Dec 21, 2017

Yesterday we switched on the BrowserStack for builds on Travis.

Current status:

image

I'm closing because everything works as we want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:task This issue reports a chore (non-production change) and other types of "todos".
Projects
None yet
Development

No branches or pull requests

3 participants