-
-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ignore spec files to allow for co-located tests (#2309)
* Ignore spec files to allow for co-located tests * Add tests
- Loading branch information
Showing
10 changed files
with
55 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ensureNoTsHeaderOrSpecFiles } from "../../../src/modules/utils/ensureNoTsHeaderOrSpecFiles"; | ||
|
||
describe("ensureNoTsHeaderOrSpecFiles", () => { | ||
it("filters header files", () => { | ||
const filtered = ensureNoTsHeaderOrSpecFiles([ | ||
"afdasf.d.ts", | ||
"some-file.ts", | ||
]); | ||
expect(filtered).toEqual(["some-file.ts"]); | ||
}); | ||
|
||
it("filters test/spec files", () => { | ||
const filtered = ensureNoTsHeaderOrSpecFiles([ | ||
"afdasf.spec.ts", | ||
"afdasfsdfa.spec.js", | ||
"spec.js", | ||
"test-my-api.js", | ||
"afdasfsdfa.test.js", | ||
"afdasfsdfa.test.ts", | ||
"some-file.ts", | ||
]); | ||
expect(filtered).toEqual(["spec.js", "test-my-api.js", "some-file.ts"]); | ||
}); | ||
}); |
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 was deleted.
Oops, something went wrong.
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,19 @@ | ||
/** | ||
*swap out d.ts files for the JS versions when running with ts-node | ||
* also filter out *.test. and *.spec. js|ts files | ||
*/ | ||
export function ensureNoTsHeaderOrSpecFiles( | ||
files: Array<string> | ||
): Array<string> { | ||
return files.filter((f) => { | ||
if (f.match(/.*\.d\.ts$/)) { | ||
return false; | ||
} | ||
|
||
if (f.match(/.*\.(?:spec|test)\.[tj]s$/)) { | ||
return false; | ||
} | ||
|
||
return true; | ||
}); | ||
} |