testit-adapter-codecept 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/build/bootstrap.d.ts +1 -0
  2. package/build/bootstrap.js +34 -0
  3. package/build/common/__tests/box.class.spec.d.ts +1 -0
  4. package/build/common/__tests/box.class.spec.js +15 -0
  5. package/build/common/__tests/test.utils.d.ts +4 -0
  6. package/build/common/__tests/test.utils.js +71 -0
  7. package/build/common/classes/box.class.d.ts +5 -0
  8. package/build/common/classes/box.class.js +18 -0
  9. package/build/common/classes/config.class.d.ts +6 -0
  10. package/build/common/classes/config.class.js +67 -0
  11. package/build/common/classes/logger.class.d.ts +9 -0
  12. package/build/common/classes/logger.class.js +28 -0
  13. package/build/common/classes/outcome.factory.d.ts +7 -0
  14. package/build/common/classes/outcome.factory.js +19 -0
  15. package/build/common/functions/compose.function.d.ts +1 -0
  16. package/build/common/functions/compose.function.js +5 -0
  17. package/build/common/functions/hash.function.d.ts +1 -0
  18. package/build/common/functions/hash.function.js +15 -0
  19. package/build/common/functions/humanize.function.d.ts +1 -0
  20. package/build/common/functions/humanize.function.js +7 -0
  21. package/build/common/functions/is-passed.function.d.ts +2 -0
  22. package/build/common/functions/is-passed.function.js +7 -0
  23. package/build/common/functions/to-iso-string.function.d.ts +1 -0
  24. package/build/common/functions/to-iso-string.function.js +10 -0
  25. package/build/common/functions/use-hash.function.d.ts +9 -0
  26. package/build/common/functions/use-hash.function.js +13 -0
  27. package/build/common/types/nullable.type.d.ts +1 -0
  28. package/build/common/types/nullable.type.js +2 -0
  29. package/build/helper.d.ts +9 -0
  30. package/build/helper.js +37 -0
  31. package/build/http/default-http-client.class.d.ts +22 -0
  32. package/build/http/default-http-client.class.js +123 -0
  33. package/build/http/http-client.errors.d.ts +7 -0
  34. package/build/http/http-client.errors.js +18 -0
  35. package/build/index.d.ts +2 -0
  36. package/build/index.js +18 -0
  37. package/build/jest.config.d.ts +7 -0
  38. package/build/jest.config.js +12 -0
  39. package/build/services/__tests/attachments.class.spec.d.ts +1 -0
  40. package/build/services/__tests/attachments.class.spec.js +23 -0
  41. package/build/services/__tests/runs.builder.spec.d.ts +1 -0
  42. package/build/services/__tests/runs.builder.spec.js +79 -0
  43. package/build/services/__tests/tests.builder.spec.d.ts +1 -0
  44. package/build/services/__tests/tests.builder.spec.js +32 -0
  45. package/build/services/attachments.service.d.ts +11 -0
  46. package/build/services/attachments.service.js +28 -0
  47. package/build/services/runs.builder.d.ts +10 -0
  48. package/build/services/runs.builder.js +65 -0
  49. package/build/services/tests.builder.d.ts +10 -0
  50. package/build/services/tests.builder.js +55 -0
  51. package/build/strategies/base-strategy.class.d.ts +24 -0
  52. package/build/strategies/base-strategy.class.js +66 -0
  53. package/build/strategies/default-strategy.class.d.ts +16 -0
  54. package/build/strategies/default-strategy.class.js +44 -0
  55. package/build/strategies/partial-startegy.class.d.ts +20 -0
  56. package/build/strategies/partial-startegy.class.js +72 -0
  57. package/build/strategies/scratch-strategy.class.d.ts +18 -0
  58. package/build/strategies/scratch-strategy.class.js +49 -0
  59. package/build/strategies/strategy.factory.d.ts +8 -0
  60. package/build/strategies/strategy.factory.js +21 -0
  61. package/build/types/codecept.type.d.ts +27 -0
  62. package/build/types/codecept.type.js +2 -0
  63. package/build/types/origin.type.d.ts +46 -0
  64. package/build/types/origin.type.js +2 -0
  65. package/build/types/strategy.type.d.ts +10 -0
  66. package/build/types/strategy.type.js +2 -0
  67. package/package.json +2 -2
  68. package/testit-adapter-codecept-1.1.2.tgz +0 -0
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScratchStrategy = void 0;
4
+ const attachments_service_1 = require("../services/attachments.service");
5
+ const base_strategy_class_1 = require("./base-strategy.class");
6
+ class ScratchStrategy extends base_strategy_class_1.BaseStrategy {
7
+ constructor(http, logger, config) {
8
+ super(http, logger, config);
9
+ this.http = http;
10
+ this.logger = logger;
11
+ this.config = config;
12
+ this.attachments = new attachments_service_1.AttachmentsService(this.http);
13
+ }
14
+ async bootstrap() {
15
+ var _a;
16
+ const run = await this.http.createEmptyRun((_a = this.config.testRunName) !== null && _a !== void 0 ? _a : '');
17
+ if (run) {
18
+ await this.http.startRunIfNeeded(run.id);
19
+ this.run = run;
20
+ }
21
+ }
22
+ async teardown() {
23
+ await this.http.completeRunIfNeeded(this.run.id);
24
+ }
25
+ async transferTestsToSystem(suite) {
26
+ await this.createOrUpdateTests(suite);
27
+ }
28
+ async transferRunsToSystem(suite) {
29
+ var _a, _b, _c;
30
+ for (const test of suite.tests) {
31
+ const config = this.box.get(test.id);
32
+ const screenshot = (_a = test.artifacts) === null || _a === void 0 ? void 0 : _a.screenshot;
33
+ const clientUrls = (_b = config === null || config === void 0 ? void 0 : config.attachments) !== null && _b !== void 0 ? _b : [];
34
+ if (screenshot) {
35
+ clientUrls.push(screenshot);
36
+ }
37
+ const attachments = await this.attachments.attach(clientUrls);
38
+ if (config === null || config === void 0 ? void 0 : config.text) {
39
+ const attach = await this.attachments
40
+ .attachTextLikeFile(config.text.content, (_c = config.text) === null || _c === void 0 ? void 0 : _c.name);
41
+ attachments.push(attach);
42
+ }
43
+ const data = this.runsBuilder.build(test, config, attachments);
44
+ await this.http.updateRuns(data, this.run.id);
45
+ }
46
+ this.logger.log(`Test run - ${this.run.id} transferred to remote system`);
47
+ }
48
+ }
49
+ exports.ScratchStrategy = ScratchStrategy;
@@ -0,0 +1,8 @@
1
+ import { Logger } from '../common/classes/logger.class';
2
+ import { DefaultHttpClient } from '../http/default-http-client.class';
3
+ import { Strategy } from '../types/strategy.type';
4
+ import { Origin } from '../types/origin.type';
5
+ export type AdapterMode = 0 | 1 | 2;
6
+ export declare class StrategyFactory {
7
+ static create(http: DefaultHttpClient, logger: Logger, config: Origin.Config): Strategy;
8
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StrategyFactory = void 0;
4
+ const default_strategy_class_1 = require("./default-strategy.class");
5
+ const partial_startegy_class_1 = require("./partial-startegy.class");
6
+ const scratch_strategy_class_1 = require("./scratch-strategy.class");
7
+ class StrategyFactory {
8
+ static create(http, logger, config) {
9
+ var _a;
10
+ const strategies = {
11
+ 0: () => new partial_startegy_class_1.PartialStrategy(http, logger, config),
12
+ 1: () => new default_strategy_class_1.DefaultStrategy(http, logger, config),
13
+ 2: () => new scratch_strategy_class_1.ScratchStrategy(http, logger, config)
14
+ };
15
+ if (!strategies[config === null || config === void 0 ? void 0 : config.adapterMode]) {
16
+ logger.warn(`This mode ${config === null || config === void 0 ? void 0 : config.adapterMode} is invalid. Use mode 0, 1, 2`);
17
+ }
18
+ return strategies[(_a = config === null || config === void 0 ? void 0 : config.adapterMode) !== null && _a !== void 0 ? _a : 0]();
19
+ }
20
+ }
21
+ exports.StrategyFactory = StrategyFactory;
@@ -0,0 +1,27 @@
1
+ /// <reference types="codeceptjs" />
2
+ export declare namespace Codecept {
3
+ type Status = 'success' | 'failure';
4
+ interface Step {
5
+ name: string;
6
+ args: string[];
7
+ status: Status;
8
+ duration: number;
9
+ startTime: number;
10
+ endTime: number;
11
+ finishedAt: number;
12
+ steps: Step[];
13
+ startedAt: number;
14
+ }
15
+ interface Test<T = any> extends Mocha.Test {
16
+ id: string;
17
+ steps: Step[];
18
+ startedAt: number;
19
+ config: any;
20
+ inject: any;
21
+ artifacts: any;
22
+ err?: {
23
+ cliMessage?: () => string;
24
+ };
25
+ opts: T;
26
+ }
27
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,46 @@
1
+ import { LinkPost } from 'testit-api-client';
2
+ import { AdapterMode } from '../strategies/strategy.factory';
3
+ export declare namespace Origin {
4
+ interface TestConfig {
5
+ title?: string;
6
+ displayName?: string;
7
+ description?: string;
8
+ externalId?: string;
9
+ links: LinkPost[];
10
+ labels?: string[];
11
+ workitemIds?: [];
12
+ }
13
+ interface TestText {
14
+ name: string;
15
+ content: string;
16
+ }
17
+ interface TestMetadata {
18
+ links?: LinkPost[];
19
+ attachments?: string[];
20
+ message?: string;
21
+ text?: TestText;
22
+ }
23
+ interface Config {
24
+ url?: string;
25
+ privateToken?: string;
26
+ projectId?: string;
27
+ configurationId?: string;
28
+ testRunId?: string;
29
+ testRunName?: string;
30
+ adapterMode?: AdapterMode;
31
+ automaticCreationTestCases?: boolean;
32
+ configFile?: string;
33
+ __DEV?: boolean;
34
+ }
35
+ type EnvironmentsConfig = Partial<{
36
+ TMS_URL: string;
37
+ TMS_PRIVATE_TOKEN: string;
38
+ TMS_PROJECT_ID: string;
39
+ TMS_CONFIGURATION_ID: string;
40
+ TMS_TEST_RUN_ID: string;
41
+ TMS_TEST_RUN_NAME: string;
42
+ TMS_ADAPTER_MODE: AdapterMode;
43
+ TMS_AUTOMATIC_CREATION_TEST_CASES: boolean;
44
+ TMS_CONFIG_FILE: string;
45
+ }>;
46
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ /// <reference types="codeceptjs" />
2
+ import { Origin } from './origin.type';
3
+ export interface Strategy {
4
+ bootstrap(): Promise<any>;
5
+ teardown(): Promise<any>;
6
+ beforeTest(test: Mocha.Test): Promise<void>;
7
+ transferTestsToSystem(suite: Mocha.Suite): Promise<void>;
8
+ transferRunsToSystem(suite: Mocha.Suite): Promise<void>;
9
+ collect(id: string, data: Origin.TestMetadata): void;
10
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testit-adapter-codecept",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Codecept adapter for TestIT",
5
5
  "keywords": [],
6
6
  "main": "build/index.js",
@@ -16,7 +16,7 @@
16
16
  "dependencies": {
17
17
  "dotenv": "^16.0.3",
18
18
  "npm-run-all": "^4.1.5",
19
- "testit-api-client": "^1.0.6"
19
+ "testit-api-client": "^1.0.8"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@codeceptjs/configure": "^0.10.0",