-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Normalize config and remove unecessary checks #7801
Normalize config and remove unecessary checks #7801
Conversation
caeb2ae
to
3b48d87
Compare
Removing the property checks should be fine, |
e6565ec
to
21f8476
Compare
@lekterable CI is unhappy. Don't hesitate to ask if you're stuck :) |
@SimenB yeah I feel a little bit stuck because I can't figure out to which |
Yeah, that's a pretty obscure error. Looks like the added |
21f8476
to
acee5a1
Compare
Hey guys, I've started over again with this branch and I think I've found a bug in
|
Awesome! That error is since a new package we've added hasn't been symlinked yet. Just run |
@lekterable if you could convert Here's a diff you can apply: diff --git i/TestUtils.ts w/TestUtils.ts
index 1c588f058..ba80887bd 100644
--- i/TestUtils.ts
+++ w/TestUtils.ts
@@ -3,15 +3,12 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
- *
- * @flow
*/
-'use strict';
-
-import type {GlobalConfig, ProjectConfig} from 'types/Config';
+// eslint-disable-next-line import/no-extraneous-dependencies
+import {Config} from '@jest/types';
-const DEFAULT_GLOBAL_CONFIG: GlobalConfig = {
+const DEFAULT_GLOBAL_CONFIG: Config.GlobalConfig = {
bail: 0,
changedFilesWithAncestor: false,
changedSince: '',
@@ -67,7 +64,7 @@ const DEFAULT_GLOBAL_CONFIG: GlobalConfig = {
watchman: false,
};
-const DEFAULT_PROJECT_CONFIG: ProjectConfig = {
+const DEFAULT_PROJECT_CONFIG: Config.ProjectConfig = {
automock: false,
browser: false,
cache: false,
@@ -124,7 +121,9 @@ const DEFAULT_PROJECT_CONFIG: ProjectConfig = {
watchPathIgnorePatterns: [],
};
-export const makeGlobalConfig = (overrides: Object = {}): GlobalConfig => {
+export const makeGlobalConfig = (
+ overrides: Partial<Config.GlobalConfig> = {},
+): Config.GlobalConfig => {
const overridesKeys = new Set(Object.keys(overrides));
Object.keys(DEFAULT_GLOBAL_CONFIG).forEach(key => overridesKeys.delete(key));
@@ -138,7 +137,9 @@ export const makeGlobalConfig = (overrides: Object = {}): GlobalConfig => {
return {...DEFAULT_GLOBAL_CONFIG, ...overrides};
};
-export const makeProjectConfig = (overrides: Object = {}): ProjectConfig => {
+export const makeProjectConfig = (
+ overrides: Partial<Config.ProjectConfig> = {},
+): Config.ProjectConfig => {
const overridesKeys = new Set(Object.keys(overrides));
Object.keys(DEFAULT_PROJECT_CONFIG).forEach(key => overridesKeys.delete(key));
@@ -149,5 +150,5 @@ export const makeProjectConfig = (overrides: Object = {}): ProjectConfig => {
`);
}
- return {...DEFAULT_GLOBAL_CONFIG, ...overrides};
+ return {...DEFAULT_PROJECT_CONFIG, ...overrides};
}; |
done @SimenB , let me know what you think 😄 |
You can fix flow by adding 2 |
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.
This is great, thanks!
Will merge when CI is happy 🙂
Codecov Report
@@ Coverage Diff @@
## master #7801 +/- ##
==========================================
- Coverage 65.42% 65.37% -0.06%
==========================================
Files 255 255
Lines 9949 9940 -9
Branches 1039 1029 -10
==========================================
- Hits 6509 6498 -11
- Misses 3193 3194 +1
- Partials 247 248 +1
Continue to review full report at Codecov.
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
shouldInstrument
function expects the config object to be normalized, but some of the unit tests don't respect that so I've tried to change this. When we will be sure that the received config is normalized we can remove the additional checks from the conditions inshouldInstrument.js
file.This is work in progress, but I've wanted to hear your opinion regarding my modified version of
testShouldInstrument
function in theshould_instrument.test.js
file. Can you think of any cases that can break this? Is it better to just simply provide a normalized config as an argument every time?I'm taking care of the failed unit tests right now, any clues how to approach this?
Test plan
Adjusted unit tests. If we are certain that
shouldInstrument
receives normalized config, I think it should be enough.