Skip to content

Commit

Permalink
feat: support step and attach methods for test cases.
Browse files Browse the repository at this point in the history
```javascript
import { qase } from 'testcafe-qase-reporter/qase';

test('test', async (t) => {
  qase.attach({ name: 'attachment.txt', content: 'Hello, world!', contentType: 'text/plain' });

  await qase.step('Step 1', async (s1) => {
    await s1.step('Step 1.1', async (s11) => {
      await s11.step('Step 1.1.1', async (s111) => {
        s11.attach({ name: 'attachment.txt', content: 'Hello, world!', contentType: 'text/plain' });
        await s111.expect(true).ok();
      });
    });
    await t.expect(true).ok();
  });
  await t.expect(true).ok();
});
```
  • Loading branch information
gibiw committed Nov 11, 2024
1 parent ad4e315 commit 99f8455
Show file tree
Hide file tree
Showing 15 changed files with 445 additions and 101 deletions.
39 changes: 39 additions & 0 deletions examples/testcafe/attachmentTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { test } from 'testcafe';
import { qase } from 'testcafe-reporter-qase/qase';

fixture`Attachment tests`
.page`http://devexpress.github.io/testcafe/example/`;

test('Test with file attachment success', async (t) => {
qase.attach({ paths: ['examples/testcafe/attachmentTests.js'] });
await t.expect(true).ok();
});

test('Test with file attachment failed', async (t) => {
qase.attach({ paths: ['examples/testcafe/attachmentTests.js'] });
await t.expect(false).ok();
});

test('Test with content attachment success', async (t) => {
qase.attach({ name: 'log.txt', content: 'Hello, World!', type: 'text/plain' });
await t.expect(true).ok();
});

test('Test with content attachment failed', async (t) => {
qase.attach({ name: 'log.txt', content: 'Hello, World!', type: 'text/plain' });
await t.expect(false).ok();
});

test('Test with step attachment success', async (t) => {
await qase.step('Step with attachment', async (s) => {
s.attach({ name: 'log.txt', content: 'Hello, World!', type: 'text/plain' });
});
await t.expect(true).ok();
});

test('Test with step attachment failed', async (t) => {
await qase.step('Step with attachment', async (s) => {
s.attach({ name: 'log.txt', content: 'Hello, World!', type: 'text/plain' });
});
await t.expect(false).ok();
});
4 changes: 2 additions & 2 deletions examples/testcafe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"name": "examples-testcafe",
"private": true,
"scripts": {
"test": "QASE_MODE=testops npx testcafe \"chrome\" test.js test2.js -r spec,qase -s path=screenshots,takeOnFails=true"
"test": "QASE_MODE=testops npx testcafe \"chrome\" simpleTests.js attachmentTests.js -r spec,qase -s path=screenshots,takeOnFails=true"
},
"devDependencies": {
"eslint-plugin-testcafe": "^0.2.1",
"testcafe": "^2.6.0",
"testcafe-reporter-qase": "^2.0.0-beta.2"
"testcafe-reporter-qase": "^2.0.3"
}
}
51 changes: 51 additions & 0 deletions examples/testcafe/simpleTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { test } from 'testcafe';
import { qase } from 'testcafe-reporter-qase/qase';

fixture`Simple tests`
.page`http://devexpress.github.io/testcafe/example/`;

test('Test without metadata success', async (t) => {
await t.expect(true).ok();
});

test('Test without metadata failed', async (t) => {
await t.expect(false).ok();
});

test.meta(qase.id(1).create())('Test with QaseID success', async t => {
await t.expect(true).ok();
});

test.meta(qase.id(2).create())('Test with QaseID failed', async t => {
await t.expect(false).ok();
});

test.meta(qase.title('Test with title success').create())('Test with title success', async t => {
await t.expect(true).ok();
});

test.meta(qase.title('Test with title failed').create())('Test with title failed', async t => {
await t.expect(false).ok();
});

test.meta(qase.fields({
'description': 'Test description',
'preconditions': 'Some text',
}).create())('Test with fields success', async t => {
await t.expect(true).ok();
});

test.meta(qase.fields({
'description': 'Test description',
'preconditions': 'Some text',
}).create())('Test with fields failed', async t => {
await t.expect(false).ok();
});

test.meta(qase.ignore().create())('Test with ignore success', async t => {
await t.expect(true).ok();
});

test.meta(qase.ignore().create())('Test with ignore failed', async t => {
await t.expect(false).ok();
});
38 changes: 0 additions & 38 deletions examples/testcafe/test.js

This file was deleted.

29 changes: 0 additions & 29 deletions examples/testcafe/test2.js

This file was deleted.

15 changes: 8 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions qase-cypress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ parameterize your tests.
- `qase.groupParameters` - set the group parameters of the test case
- `qase.ignore` - ignore the test case in Qase. The test will be executed, but the results will not be sent to Qase.
- `qase.step` - create a step in the test case
- `qase.attach` - attach a file or content to the test case

For detailed instructions on using annotations and methods, refer to [Usage](docs/usage.md).

For example:

Expand Down
39 changes: 22 additions & 17 deletions qase-testcafe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,28 @@ To update a test project using testcafe-reporter-qaser@v1 to version 2:
The TestCafe reporter has the ability to auto-generate test cases
and suites from your test data.

But if necessary, you can independently register the ID of already
existing test cases from TMS before the executing tests. Meta key should be `CID`.
You should assign list of case IDs to it, e.g.:
You can also annotate the tests with the IDs of existing test cases
from Qase.io before executing tests. It's a more reliable way to bind
autotests to test cases, that persists when you rename, move, or
parameterize your tests.

```js
test.meta('CID', [1])('Text typing basics', async (t) => {
await t;
});
### Metadata

- `qase.title` - set the title of the test case
- `qase.fields` - set the fields of the test case
- `qase.suite` - set the suite of the test case
- `qase.comment` - set the comment of the test case
- `qase.parameters` - set the parameters of the test case
- `qase.groupParameters` - set the group parameters of the test case
- `qase.ignore` - ignore the test case in Qase. The test will be executed, but the results will not be sent to Qase.
- `qase.step` - create a step in the test case
- `qase.attach` - attach a file or content to the test case

For detailed instructions on using annotations and methods, refer to [Usage](docs/usage.md).

For example:

```js
const q = qase.id(1)
.title('Text typing basics')
.field({ 'severity': 'high' })
Expand Down Expand Up @@ -98,16 +111,8 @@ Example `qase.config.json` file:
}
```

Supported ENV variables:

- `QASE_MODE` - Same as `mode`
- `QASE_DEBUG` - Same as `debug`
- `QASE_ENVIRONMENT` - Same as `environment`
- `QASE_TESTOPS_API_TOKEN` - Same as `testops.api.token`
- `QASE_TESTOPS_PROJECT` - Same as `testops.project`
- `QASE_TESTOPS_RUN_ID` - Pass Run ID from ENV and override reporter option `testops.run.id`
- `QASE_TESTOPS_RUN_TITLE` - Same as `testops.run.title`
- `QASE_TESTOPS_RUN_DESCRIPTION` - Same as `testops.run.description`
Check out the example of configuration for multiple reporters in the
[demo project](../examples/testcafe/qase.config.json).

## Requirements

Expand Down
25 changes: 25 additions & 0 deletions qase-testcafe/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
# [email protected]

## What's new

Support `step` and `attach` methods for test cases.

```javascript
import { qase } from 'testcafe-qase-reporter/qase';

test('test', async (t) => {
qase.attach({ name: 'attachment.txt', content: 'Hello, world!', contentType: 'text/plain' });

await qase.step('Step 1', async (s1) => {
await s1.step('Step 1.1', async (s11) => {
await s11.step('Step 1.1.1', async (s111) => {
s11.attach({ name: 'attachment.txt', content: 'Hello, world!', contentType: 'text/plain' });
await s111.expect(true).ok();
});
});
await t.expect(true).ok();
});
await t.expect(true).ok();
});
```

# [email protected]

## What's new
Expand Down
Loading

0 comments on commit 99f8455

Please sign in to comment.