-
-
Notifications
You must be signed in to change notification settings - Fork 65
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 #192 from quinnturner/test-getters-setters
Add failing test case for missing setters
- Loading branch information
Showing
5 changed files
with
82 additions
and
19 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,16 @@ | ||
{ | ||
"version": "1.0.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Jest: current file", | ||
"program": "${workspaceFolder}/node_modules/.bin/jest", | ||
"args": ["${fileBasenameNoExtension}"], | ||
"console": "integratedTerminal", | ||
"windows": { | ||
"program": "${workspaceFolder}/node_modules/jest/bin/jest" | ||
} | ||
} | ||
] | ||
} |
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 |
---|---|---|
@@ -1,7 +1,4 @@ | ||
const ts_preset = require('ts-jest/presets/default-esm/jest-preset.js'); | ||
const puppeteer_preset = require('jest-puppeteer/jest-preset.js'); | ||
const ts_preset = require("ts-jest/presets/default-esm/jest-preset.js"); | ||
const puppeteer_preset = require("jest-puppeteer/jest-preset.js"); | ||
|
||
module.exports = Object.assign( | ||
ts_preset, | ||
puppeteer_preset | ||
); | ||
module.exports = Object.assign(ts_preset, puppeteer_preset); |
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
module.exports = { | ||
launch: { | ||
dumpio: true, | ||
headless: process.env.HEADLESS !== 'false', | ||
}, | ||
server: { | ||
command: 'npm run test-puppeteer-serve', | ||
port: 4444, | ||
launchTimeout: 10000, | ||
debug: true, | ||
}, | ||
} | ||
launch: { | ||
dumpio: true, | ||
headless: process.env.HEADLESS !== "false", | ||
}, | ||
server: { | ||
command: "npm run test-puppeteer-serve", | ||
port: 4444, | ||
launchTimeout: 10000, | ||
debug: true, | ||
}, | ||
}; |
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,42 @@ | ||
import { ok } from "assert"; | ||
import "ts-jest"; | ||
import { Logger } from "../../src/index.js"; | ||
import { mockConsoleLog } from "./helper.js"; | ||
|
||
class MissingSetter { | ||
get test(): string { | ||
return "test"; | ||
} | ||
} | ||
|
||
const missingSetter = { | ||
get test(): string { | ||
return "test"; | ||
} | ||
} | ||
|
||
describe("Getters and setters", () => { | ||
beforeEach(() => { | ||
mockConsoleLog(true, false); | ||
}); | ||
test("[class] should not print getters", (): void => { | ||
const logger = new Logger({ | ||
type: "hidden", | ||
}); | ||
const missingSetterObj = new MissingSetter(); | ||
|
||
const result = logger.info(missingSetterObj); | ||
|
||
ok(result); | ||
Object.keys(result).forEach((key) => { | ||
expect(key).not.toBe("test"); | ||
}); | ||
}); | ||
test("[object] should print getters", (): void => { | ||
const logger = new Logger({ | ||
type: "hidden", | ||
}); | ||
const result = logger.info(missingSetter); | ||
expect(result).toContain("test"); | ||
}); | ||
}); |