From 2bff575c84964eb48f9a3d9db7a49b22fe463c75 Mon Sep 17 00:00:00 2001 From: Roman Kuznetsov Date: Mon, 30 Sep 2024 13:23:01 +0300 Subject: [PATCH] feat: use 'testplane.config.[tj]s' config name --- src/constants/packageManagement.ts | 8 ++++++-- src/fsUtils.test.ts | 2 +- src/package.test.ts | 9 ++++++++- src/utils/configTemplates/js.ts | 2 +- src/utils/configTemplates/ts.ts | 2 +- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/constants/packageManagement.ts b/src/constants/packageManagement.ts index 359c860..a0e4b46 100644 --- a/src/constants/packageManagement.ts +++ b/src/constants/packageManagement.ts @@ -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", 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"; diff --git a/src/fsUtils.test.ts b/src/fsUtils.test.ts index 05028bb..5bee8d7 100644 --- a/src/fsUtils.test.ts +++ b/src/fsUtils.test.ts @@ -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 () => { diff --git a/src/package.test.ts b/src/package.test.ts index 7e13989..24aa1b3 100644 --- a/src/package.test.ts +++ b/src/package.test.ts @@ -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", + ".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 => diff --git a/src/utils/configTemplates/js.ts b/src/utils/configTemplates/js.ts index efba7eb..383c7e7 100644 --- a/src/utils/configTemplates/js.ts +++ b/src/utils/configTemplates/js.ts @@ -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}');`, diff --git a/src/utils/configTemplates/ts.ts b/src/utils/configTemplates/ts.ts index 99b1cac..a221a5d 100644 --- a/src/utils/configTemplates/ts.ts +++ b/src/utils/configTemplates/ts.ts @@ -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}";`,