Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use 'testplane.config.[tj]s' config name #40

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/constants/packageManagement.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
export const PACKAGE_JSON = "package.json";

export const CONFIG_NAMES = {
TESTPLANE_NEW_TS: "testplane.config.ts",
TESTPLANE_NEW_CTS: "testplane.config.cts",
TESTPLANE_NEW_JS: "testplane.config.js",
TESTPLANE_NEW_CJS: "testplane.config.cjs",
Comment on lines +4 to +7
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут перечисляем список, чтобы кидать ошибку при попытке перезаписать имеющийся конфиг (проинициализировать testplane в проекте, где он уже есть):

Looks like .../my-project-dir already contains "testplane.config.ts".
Please remove old config or choose another directory.
Looks like .../my-project-dir already contains ".testplane.conf.ts".
Please remove old config or choose another directory.

TESTPLANE_TS: ".testplane.conf.ts",
TESTPLANE_JS: ".testplane.conf.js",
HERMIONE_TS: ".hermione.conf.ts", // drop after testplane@2
HERMIONE_JS: ".hermione.conf.js", // drop after testplane@2
HERMIONE_TS: ".hermione.conf.ts", // drop after testplane@9
HERMIONE_JS: ".hermione.conf.js", // drop after testplane@9
} as const;

export const DEFAULT_PM = "npm";
Expand Down
2 changes: 1 addition & 1 deletion src/fsUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe("fsUtils", () => {

await fsUtils.writeTestplaneConfig("/", config);

expect(fsPromises.writeFile).toBeCalledWith(`/.testplane.conf.${ext}`, expectedConfigWritten);
expect(fsPromises.writeFile).toBeCalledWith(`/testplane.config.${ext}`, expectedConfigWritten);
};

it("js config", async () => {
Expand Down
9 changes: 8 additions & 1 deletion src/package.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ describe("package", () => {
});

describe("initApp", () => {
[".testplane.conf.ts", ".testplane.conf.js", ".hermione.conf.ts", ".hermione.conf.js"].forEach(configName => {
[
".testplane.conf.ts",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can get names from CONFIG_NAMES constant instead of manually synchronizing them here

Copy link
Member Author

@KuznetsovRoman KuznetsovRoman Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is good in source files, but i dont think it is in test files. I want small typo in CONFIG_NAMES to break these tests, so you would double-check it here

".testplane.conf.js",
".hermione.conf.ts",
".hermione.conf.js",
"testplane.config.ts",
"testplane.config.cjs",
].forEach(configName => {
it(`should throw an error, if ${configName} exists`, async () => {
const dirPath = "/dir/path";
jest.mocked(fsUtils.exists).mockImplementation(file =>
Expand Down
2 changes: 1 addition & 1 deletion src/utils/configTemplates/js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ConfigTemplate } from ".";
import { CONFIG_NAMES } from "../../constants/packageManagement";

export const jsTemplate: ConfigTemplate = {
fileName: CONFIG_NAMES.TESTPLANE_JS,
fileName: CONFIG_NAMES.TESTPLANE_NEW_JS,
language: "js",
quote: "'",
getImportModule: (importName, moduleName) => `const ${importName} = require('${moduleName}');`,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/configTemplates/ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ConfigTemplate } from ".";
import { CONFIG_NAMES } from "../../constants/packageManagement";

export const tsTemplate: ConfigTemplate = {
fileName: CONFIG_NAMES.TESTPLANE_TS,
fileName: CONFIG_NAMES.TESTPLANE_NEW_TS,
language: "ts",
quote: '"',
getImportModule: (importName, moduleName) => `import ${importName} from "${moduleName}";`,
Expand Down
Loading