-
Notifications
You must be signed in to change notification settings - Fork 41
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
Moved from jest to jasmine-karma #189
Conversation
Hi @koonpeng, I moved and ran all the react-component tests with Jasmine and Karma. Now I am fighting to integrate the coverage test. |
We have this warning: It looks like there are several instances of It's an open issue. https://material-ui.com/getting-started/faq/#i-have-several-instances-of-styles-on-the-page alias: {
|
If we want html coverage reports we should use "istanbul-instrumenter-loader": "^0.2.0", webpack-contrib/istanbul-instrumenter-loader#32 |
Having this error on the CI
Solved |
b29eece
to
0521e64
Compare
Codecov Report
@@ Coverage Diff @@
## master #189 +/- ##
==========================================
- Coverage 69.25% 64.44% -4.82%
==========================================
Files 107 92 -15
Lines 2885 2607 -278
Branches 605 485 -120
==========================================
- Hits 1998 1680 -318
+ Misses 880 820 -60
- Partials 7 107 +100
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@koonpeng Ready for first comments. =) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make another PR (or in this PR) to see if we can replace the smoke tests with screenshot snapshot diffing?
// TextEncoder is not available in node | ||
colorManager = new ColorManager(); | ||
handler = { | ||
onClick: () => console.log('mock'), | ||
robotColor: async () => 'black', | ||
}; | ||
|
||
spyOn(handler, 'onClick'); | ||
spyOn(handler, 'robotColor'); | ||
|
||
colorManager.robotPrimaryColor = handler.robotColor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are running the tests in browser, this comment shouldn't be valid anymore. There also shouldn't be a need to mock ColorManager
now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a lot of errors without instantiating ColorManager.
ERROR in [at-loader] ./tests/robots/robot-marker.spec.tsx:23:32
TS2739: Type 'Spy<Func>' is missing the following properties from type 'ColorManager': conflictHighlight, robotPrimaryColor, robotColorFromCache, _robotColorFromId, _robotColorCache
ERROR in [at-loader] ./tests/robots/robot-marker.spec.tsx:32:32
TS2322: Type 'Spy<Func>' is not assignable to type 'ColorManager'.
Also, I think we need that for this test to work:
colorManager.robotPrimaryColor = jasmine.CreateSpy();
it("uses ColorManager to determine robot's color", async () => {
await render(<RobotMarker robot={makeRobot()} fleetName="test_fleet" footprint={1} />);
expect(colorManager.robotPrimaryColor).toHaveBeenCalled();
});
Since we are using a monorepo, the |
@@ -13,28 +13,49 @@ | |||
"clean": "tsc --build --clean", | |||
"test": "jest --watch", | |||
"test:coverage": "jest --ci --coverage", | |||
"test:karma": "./node_modules/karma/bin/karma start karma.conf.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
Is it possible to use the karma cli?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use it if we install karma-cli
globally, but I think that for that reason, dependency should be outside the package.json
. Let me know what do you think is the best aproach
Alright, I'll open a new PR |
Looks like this got nuked when we change |
What's new
Moved react-components tests from
jest/jsdom
tojasmine/karma
.Observations:
.test
extension to.spec
for karma to work.jest.fn()
. But we can use an empty function andspyOn
.typescript-karma
compiler but it's not working great when we deal with third-party libraries and CSS. Webpack do the pre-processing for us and it's more flexible so, I opted to go with Webpack.Self-checks