testit-adapter-jest 1.1.0 → 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.
package/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Test IT TMS adapters for Jest
2
2
  ![Test IT](https://raw.githubusercontent.com/testit-tms/adapters-js/master/images/banner.png)
3
3
 
4
- # Cucumber
5
-
6
4
  ## Getting Started
7
5
 
8
6
  ### Compatibility
@@ -10,7 +8,6 @@
10
8
  | Test IT | Adapter |
11
9
  |---------|---------|
12
10
  | 3.5 | 1.0 |
13
- |---------|---------|
14
11
  | 4.0 | 1.1 |
15
12
 
16
13
  ### Installation
@@ -65,6 +62,8 @@ module.exports = {
65
62
  projectId: '<id>',
66
63
  configurationId: '<id>',
67
64
  testRunId: '<optional id>',
65
+ adapterMode: <optional>,
66
+ automaticCreationTestCases: <optional boolean>
68
67
  },
69
68
  };
70
69
  ```
@@ -92,11 +91,20 @@ module.exports = {
92
91
 
93
92
  * `testRunId` - id of the created test run in TMS instance. `testRunId` is optional. If it is not provided, it is created automatically.
94
93
 
95
- * `testRunName` - parameter for specifying the name of test run in TMS instance. `testRunName` is optional. If it is not provided, it is created automatically.
94
+ * `testRunName` - parameter for specifying the name of test run in TMS instance. `testRunName` is optional. If it is not provided, it is created automatically.
95
+
96
+ * `adapterMode` - adapter mode. Default value - 0. The adapter supports following modes:
97
+ * 0 - in this mode, the adapter filters tests by test run ID and configuration ID, and sends the results to the test run.
98
+ * 1 - in this mode, the adapter sends all results to the test run without filtering.
99
+ * 2 - in this mode, the adapter creates a new test run and sends results to the new test run.
100
+
101
+ * `automaticCreationTestCases` - mode of automatic creation test cases. Default value - false. The adapter supports following modes:
102
+ * true - in this mode, the adapter will create a test case linked to the created autotest (not to the updated autotest).
103
+ * false - in this mode, the adapter will not create a test case.
96
104
 
97
105
  #### Command line
98
106
 
99
- You can also specify options via cli arguments `jest --testEnvironment testit-adapter-jest --testEnvironmentOptions "{\"url\":\"<url>\",\"privateToken\":\"<token>\",\"projectId\":\"<id>\",\"configurationId\":\"<id>\",\"testRunId\":\"<optional id>\"}" --globalSetup testit-adapter-jest/dist/globalSetup.js --globalTeardown testit-adapter-jest/dist/globalTeardown.js`
107
+ You can also specify options via cli arguments `jest --testEnvironment testit-adapter-jest --testEnvironmentOptions "{\"url\":\"<url>\",\"privateToken\":\"<token>\",\"projectId\":\"<id>\",\"configurationId\":\"<id>\",\"testRunId\":\"<optional id>\",\"automaticCreationTestCases\": <optional boolean>}" --globalSetup testit-adapter-jest/dist/globalSetup.js --globalTeardown testit-adapter-jest/dist/globalTeardown.js`
100
108
 
101
109
 
102
110
  ### Methods
@@ -4,6 +4,7 @@ const testClient_1 = require("./testClient");
4
4
  const utils_1 = require("./utils");
5
5
  exports.default = async (globalConfig, projectConfig) => {
6
6
  const adapterMode = projectConfig.testEnvironmentOptions?.adapterMode ?? 0;
7
+ const automaticCreationTestCases = projectConfig.testEnvironmentOptions?.automaticCreationTestCases ?? false;
7
8
  let testRunId;
8
9
  try {
9
10
  switch (adapterMode) {
@@ -30,4 +31,5 @@ exports.default = async (globalConfig, projectConfig) => {
30
31
  process.exit(1);
31
32
  }
32
33
  projectConfig.globals['testRunId'] = testRunId;
34
+ projectConfig.globals['automaticCreationTestCases'] = automaticCreationTestCases;
33
35
  };
@@ -14,6 +14,7 @@ export default class TestItEnvironment extends NodeEnvironment {
14
14
  private autotests;
15
15
  private testPath;
16
16
  private attachmentsQueue;
17
+ private automaticCreationTestCases;
17
18
  constructor(config: JestEnvironmentConfig, context: EnvironmentContext);
18
19
  setup(): Promise<void>;
19
20
  teardown(): Promise<void>;
@@ -36,9 +36,14 @@ class TestItEnvironment extends jest_environment_node_1.default {
36
36
  this.autotests = [];
37
37
  this.attachmentsQueue = [];
38
38
  const testRunId = config.projectConfig.globals['testRunId'];
39
+ const automaticCreationTestCases = config.projectConfig.globals['automaticCreationTestCases'];
39
40
  if (!testRunId || typeof testRunId !== 'string') {
40
41
  throw new Error('Looks like globalSetup was not called');
41
42
  }
43
+ if (!automaticCreationTestCases || typeof automaticCreationTestCases !== 'boolean') {
44
+ throw new Error('Looks like globalSetup was not called');
45
+ }
46
+ this.automaticCreationTestCases = automaticCreationTestCases;
42
47
  this.testClient = new testClient_1.TestClient({
43
48
  ...config.projectConfig.testEnvironmentOptions,
44
49
  testRunId,
@@ -193,6 +198,7 @@ class TestItEnvironment extends jest_environment_node_1.default {
193
198
  teardown: teardownSteps.map(mappers_1.mapStep),
194
199
  links: autotest.links,
195
200
  labels: autotest.labels.map((label) => ({ name: label })),
201
+ shouldCreateWorkItem: this.automaticCreationTestCases,
196
202
  };
197
203
  if (!result.isFailed) {
198
204
  await this.testClient.loadPassedAutotest(autotestPost);
@@ -224,7 +230,7 @@ class TestItEnvironment extends jest_environment_node_1.default {
224
230
  outcome: result.isFailed ? 'Failed' : 'Passed',
225
231
  startedOn: result.startedAt ? (0, mappers_1.mapDate)(result.startedAt) : undefined,
226
232
  duration: result.duration ? result.duration : undefined,
227
- completeOn: result.finishedAt ? (0, mappers_1.mapDate)(result.finishedAt) : undefined,
233
+ completedOn: result.finishedAt ? (0, mappers_1.mapDate)(result.finishedAt) : undefined,
228
234
  attachments: (0, mappers_1.mapAttachments)(autotest.attachments),
229
235
  message: messages.length > 0 ? messages.join('\n') : undefined,
230
236
  traces: result.trace,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testit-adapter-jest",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "",
5
5
  "main": "dist/testitEnvironment.js",
6
6
  "scripts": {
@@ -12,7 +12,7 @@
12
12
  "license": "ISC",
13
13
  "dependencies": {
14
14
  "debug": "^4.3.4",
15
- "testit-api-client": "^1.0.5"
15
+ "testit-api-client": "^1.0.8"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@types/debug": "^4.1.7",