-
Notifications
You must be signed in to change notification settings - Fork 3k
test(filter): enable type inference to marble diagram #2202
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ cache: | |
env: | ||
matrix: | ||
- NODE_VER=4 FULL_VALIDATE=false | ||
- NODE_VER=6 FULL_VALIDATE=true alias grunt=./node_modules/grunt-cli/bin/grunt | ||
- NODE_VER=6 FULL_VALIDATE=true alias grunt=./node_modules/grunt-cli/bin/grunt danger=./node_modules/danger/distribution/danger | ||
- NODE_VER=7 FULL_VALIDATE=false | ||
matrix: | ||
fast_finish: true | ||
|
@@ -23,6 +23,7 @@ before_install: | |
- nvm install $NODE_VER | ||
- npm install -g npm@4 && node -v && npm -v | ||
- if [ "$FULL_VALIDATE" == "true" ]; then npm install [email protected] grunt-cli grunt-contrib-connect grunt-run; fi | ||
- if [ "$FULL_VALIDATE" == "true" ] && [ -n "DANGER_GITHUB_API_TOKEN" ]; then npm install danger && danger; fi | ||
|
||
install: | ||
- npm install | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var _ = require('lodash'); | ||
|
||
//simple regex matcher to detect usage of helper function and its type signature | ||
var hotMatch = /\bhot\(/gi; | ||
var hotSignatureMatch = /\bdeclare const hot: typeof/gi; | ||
|
||
var coldMatch = /\bcold\(/gi; | ||
var coldSignatureMatch = /\bdeclare const cold: typeof/gi; | ||
|
||
var errorCount = 0; | ||
|
||
// Warn when PR size is large | ||
var bigPRThreshold = 600; | ||
if (danger.github.pr.additions + danger.github.pr.deletions > bigPRThreshold) { | ||
warn(':exclamation: Big PR (' + ++errorCount + ')'); | ||
markdown('> (' + errorCount + ') : Pull Request size seems relatively large. If Pull Request contains multiple changes, split each into separate PR will helps faster, easier review.'); | ||
} | ||
|
||
// Check test exclusion (.only) is included | ||
var modifiedSpecFiles = danger.git.modified_files.filter(function (filePath) { | ||
return filePath.match(/-spec.(js|jsx|ts|tsx)$/gi); | ||
}); | ||
|
||
var testFilesIncludeExclusion = modifiedSpecFiles.reduce(function (acc, value) { | ||
var content = fs.readFileSync(value).toString(); | ||
var invalid = _.includes(content, 'it.only') || _.includes(content, 'describe.only'); | ||
if (invalid) { | ||
acc.push(path.basename(value)); | ||
} | ||
return acc; | ||
}, []); | ||
|
||
if (testFilesIncludeExclusion.length > 0) { | ||
fail('an \`only\` was left in tests (' + testFilesIncludeExclusion + ')'); | ||
} | ||
|
||
// Check test cases missing type signature import for test marble helper functions | ||
var testFilesMissingTypes = modifiedSpecFiles.reduce(function (acc, value) { | ||
var content = fs.readFileSync(value).toString(); | ||
|
||
var hotFnMatches = content.match(hotMatch) && content.match(hotSignatureMatch); | ||
var coldFnMatches = content.match(coldMatch) && content.match(coldSignatureMatch); | ||
|
||
if (!hotFnMatches || !coldFnMatches) { | ||
acc.push(path.basename(value)); | ||
} | ||
|
||
return acc; | ||
}, []); | ||
|
||
if (testFilesMissingTypes.length > 0) { | ||
fail('missing type definition import in tests (' + testFilesMissingTypes + ') (' + ++errorCount + ')'); | ||
markdown('> (' + errorCount + ') : It seems updated test cases uses test scheduler interface `hot`, `cold` but miss to import type signature for those.'); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
How about
import * as marbleTestingSignature from '../helpers/marble-testing';
?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.
I haven't tried it but tempted to leave as-is to give clarity this import is unique kind and not being used in general.
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.
That intent may be better expressed as a comment, not as the usage of
require
.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.
could you not just destructure it with the import?
import {hot, cold, asDiagram, expectObservable, expectSubscriptions} from '../helpers/marble-testing';
Uh oh!
There was an error while loading. Please reload this page.
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.
No, it's #1633. If use imported module, TS will transpile it and doc will be affected, reason only use it as type to be removed while transpiling.
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.
I think a comment here is super important. I can easily see myself wondering why this was done and changing it later.