Comments (3)
Here's where I'm at so far with this.
I started by looking at some of our old MDL logs from TravisCI, e.g. https://travis-ci.org/google/material-design-lite/jobs/184278985
Combing through the massive logs led me to stuff like this:
Basically, it looked like the tests were finishing but the browser couldn't communicate with them.
I ran the tests locally in debug mode, and profiled the test execution using the Chrome Devtools timeline. Here's the result of the first three seconds:
Note the one massive function call that seems to run for the entirety of the test suite. This call completely locks up the browser, and in fact delays all of the console logging and tap reporting in karma until the suite has finished running. It could also very well delay any sort of script execution dealing with communicating with karma. This, I believe, may be the reason we're dealing with massive test execution times and disconnection issues using SauceLabs. My hypothesis is supported by the fact that are test infra became more flaky as the number of our tests increased.
When I further expected that function, I found the following to be the offending code: https://github.com/substack/tape/blob/master/lib/results.js#L68-L75
This runs all tests synchronously within the same frame, which basically means the more tests we have, the more karma's test function will degrade. Thus I came to the conclusion that tape may not be able to scale to the size of our codebase. It could be the fact that we're using tape in the browser, but nonetheless this presents a problem for us.
Once I had discovered this, I switched out tape for mocha in the following way:
- Installed
mocha
,karma-mocha
, and chai, which replaced bothtape
andkarma-tap
. - Created a fake-tape.js file that essentially duck-punched mocha into using tape's interface. This way, I could run the tests using mocha but not have to modify any of the tests' source code.
- Fooled the karma-webpack config into thinking that
import test from 'tape'
was importing tape, when really it was importingfake-tape
.
Yes, this is the ugliest hack ever, but it worked!. Here's the timeline output running the same sweet of tests with mocha
under the hood. Additionally, rather than the first 3 seconds it captures more of the test execution:
As you can see, there's no longer one single function for running tests but many different function calls spaced apart. The browser felt immediately responsive, and all of the superfluous console logging and erroneous reporter output from karma-tap has disappeared.
Next steps
Next steps are to test this setup on SauceLabs, and ideally on TravisCI using SauceLabs, perhaps via a fake pull request. If it seems to fix the flakiness, we should evaluate what the next steps our in terms of where we take our test infra.
from material-components-web.
Discussed this offline with the team. Link to chat log from convo: https://gist.github.com/traviskaufman/d47416257b86c1bbf979d7f3eee119d3
Decision was made that we definitely need to test in real browsers, since it's the only way we can verify that our code will work in all browsers we support.
We looked at bootstrap's TravisCI file and test infra for inspiration.
Decision was made to move off of tape, as mocha seems to handle the scale of our tests much better, and has first-class browser support.
Implications of this are as follows:
- Removing dependency on karma
- Rewriting / reshaping tests for mocha, rather than for tape
- Changing the way we write some of our tests, e.g. using before/after hooks rather than setupTest()
Next steps
- Determine what type of mocha interface we want to use. The Qunit-style interface looks most similar to what we already have.
- Investigate different types of setups for running mocha locally. Options include jsdom + jsdom-global, or electron-mocha.
- Investigate what it would take to refactor all tests. Investigate potentially using something like recast.
- Ensure that debugging still works in development, and coverage still works on single runs / CI.
@amsheehan @sgomes should we close this issue and create a follow-up?
from material-components-web.
👍 for closing the issue; sounds like we have a much more well-defined set of tasks. Let's create issues for those and add them to our tracker.
Thanks for the great investigative work, @traviskaufman!
from material-components-web.
Related Issues (20)
- Angular Material Tabs with sticky first tab
- The getting started guide: issues HOT 1
- [mdc-icon-button] unable to import core-styles mixin of icon-button as shown in documentation
- Unpkg: Source map for minified JS missing HOT 1
- MDCTopAppBar buttons ripple effect broken since 12.0.0 HOT 2
- Hi, I can't make a frame for the drawer, it's a problem
- Symmetric API for the Angular Material Icon Button HOT 1
- [MDCTextField] Trailing icons do not appear HOT 1
- the problem in running the program HOT 1
- [mdc-chip] css not applied to mdc-evolution-chip elements HOT 3
- Is there anyway we can force the dropdown select to always show below?
- [Chips] Filter chips not showing svg tick HOT 1
- `setAutovalidate()`/`getAutovalidate` name mismatch in readme
- Vertical mat-slider
- [mdc-theme] Contradicting advice on purpose of `$secondary`
- [Snackbar] screenreader leaves out "button" when reading message and action
- Tag for the version 14.1.0 is missing
- The release 14.1.0 isn't published on npmjs HOT 1
- Tone should work with css-variables
- [ALL] NPM packages are missing file extensions in ES6 exports
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from material-components-web.