Skip to content

Commit

Permalink
Fix TypeScript tests
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed Mar 18, 2017
1 parent 1bbc903 commit 54886c9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion dangerfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from "fs"
import includes from "lodash.includes"
fs.f

// Request a CHANGELOG entry if not declared #trivial
const hasChangelog = includes(danger.git.modified_files, "changelog.md")
const isTrivial = includes((danger.github.pr.body + danger.github.pr.title), "#trivial")
Expand Down
8 changes: 5 additions & 3 deletions source/runner/DangerfileRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async function dangerJestConfig() {
// so if you can make you tests run right,
// then it's pretty likely that Danger can do it too.
const jestConfig = await readConfig([], process.cwd())

// console.log(jestConfig)
return {
cacheDirectory: os.tmpdir(),
setupFiles: [],
Expand All @@ -65,12 +65,14 @@ async function dangerJestConfig() {
defaultPlatform: "danger-js"
},
moduleNameMapper: [],
moduleDirectories: [ "node_modules" ],
moduleFileExtensions: ["js", ...jestConfig.moduleFileExtensions],
transform: [["js$", "babel-jest"], ...jestConfig.transform],
transformIgnorePatterns: [],
testPathIgnorePatterns: jestConfig.testPathIgnorePatterns,
cache: null,
testRegex: "",
testPathDirs: [process.cwd()]
testPathDirs: [process.cwd()],
transformIgnorePatterns: [ "/node_modules/" ]
}
}

Expand Down
27 changes: 15 additions & 12 deletions source/runner/_tests/DangerRunner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,20 @@ describe("with fixtures", () => {
})
})

it.skip("can execute async/await scheduled functions", async () => {
// this test takes *forever* because of babel-polyfill being required
const context = await setupDangerfileContext()
const runtime = await createDangerfileRuntimeEnvironment(context)
const results = await runDangerfileEnvironment(resolve(fixtures, "__DangerfileAsync.js"), runtime)
expect(results.warnings).toEqual([{
message: "Async Function"
}, {
message: "After Async Function"
}])
})
// This adds > 6 seconds to the tests! Only orta should be forced into that.
if (process.env["USER"] === "orta") {
it("can execute async/await scheduled functions", async () => {
// this test takes *forever* because of babel-polyfill being required
const context = await setupDangerfileContext()
const runtime = await createDangerfileRuntimeEnvironment(context)
const results = await runDangerfileEnvironment(resolve(fixtures, "__DangerfileAsync.js"), runtime)
expect(results.warnings).toEqual([{
message: "Async Function"
}, {
message: "After Async Function"
}])
})
}

it("can schedule callback-based promised", async () => {
const context = await setupDangerfileContext()
Expand All @@ -126,7 +129,7 @@ describe("with fixtures", () => {
const context = await setupDangerfileContext()
const runtime = await createDangerfileRuntimeEnvironment(context)
const results = await runDangerfileEnvironment(resolve(fixtures, "__DangerfileTypeScript.ts"), runtime)
expect(results.warnings).toEqual([{
expect(results.messages).toEqual([{
message: "Honey, we got Types",
}])
})
Expand Down
1 change: 0 additions & 1 deletion source/runner/_tests/fixtures/__DangerfileTypeScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
// This doesn't exist in JS-world
interface MyThing {}

// Removed import
message("Honey, we got Types")

0 comments on commit 54886c9

Please sign in to comment.