Skip to content

Commit

Permalink
Merge pull request #192 from quinnturner/test-getters-setters
Browse files Browse the repository at this point in the history
Add failing test case for missing setters
  • Loading branch information
terehov authored Dec 18, 2022
2 parents deabf24 + 65231c2 commit b25abd4
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 19 deletions.
12 changes: 10 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"es2021": true
},
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],
"overrides": [],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
Expand All @@ -16,5 +15,14 @@
"linebreak-style": ["error", "unix"],
"quotes": ["error", "double"],
"semi": ["error", "always"]
}
},
"overrides": [
{
"files": ["*.cjs"],
"rules": {
"no-undef": "off",
"@typescript-eslint/no-var-requires": "off"
}
}
]
}
16 changes: 16 additions & 0 deletions .vscode/launch.json
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"
}
}
]
}
9 changes: 3 additions & 6 deletions jest-preset.cjs
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);
22 changes: 11 additions & 11 deletions jest-puppeteer.config.cjs
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,
},
};
42 changes: 42 additions & 0 deletions tests/Nodejs/14_Getters_Setters.test.ts
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");
});
});

0 comments on commit b25abd4

Please sign in to comment.