-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2202 from kwonoj/fix-test-type-inference
test(filter): enable type inference to marble diagram
- Loading branch information
Showing
19 changed files
with
106 additions
and
43 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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