@msalaam/xray-qe-toolkit 1.2.0 → 1.3.0

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 (2) hide show
  1. package/README.md +203 -25
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -11,6 +11,7 @@
11
11
  - [Installation](#installation)
12
12
  - [AI Setup (Optional)](#ai-setup-optional)
13
13
  - [Quick Start](#quick-start)
14
+ - [Playwright Quick Start](#playwright-quick-start)
14
15
  - [CLI Commands](#cli-commands)
15
16
  - [init](#xray-qe-init)
16
17
  - [gen-tests](#xray-qe-gen-tests)
@@ -421,23 +422,51 @@ npx xqt create-execution --summary "Feature XYZ" --issue QE-123
421
422
 
422
423
  Import test results into Xray Cloud. Supports JUnit XML and Playwright JSON formats. Designed for CI — no human interaction.
423
424
 
424
- **JUnit XML (JUnit, Newman, etc.):**
425
+ #### Format Comparison
426
+
427
+ | Feature | JUnit XML | Playwright JSON |
428
+ |---------|-----------|----------------|
429
+ | **Update existing tests** | ❌ No - always creates new tests | ✅ Yes - via annotations |
430
+ | **Test key mapping** | ❌ Not supported | ✅ `test.info().annotations` |
431
+ | **Attachments/Evidence** | ❌ Not supported | ✅ Supported |
432
+ | **Best for** | Newman, generic test runners | Playwright tests |
433
+ | **Recommendation** | ⚠️ Use only for tools without test keys | ✅ **Recommended for Playwright** |
434
+
435
+ #### JUnit XML (Newman, generic test runners)
436
+
437
+ ⚠️ **Important:** JUnit XML **cannot update existing Xray tests** - it will always create new test cases. Only use this for Newman or test runners that don't support test keys.
438
+
425
439
  ```bash
426
440
  npx xqt import-results --file results.xml --testExecKey QE-123
427
441
  ```
428
442
 
429
- **Playwright JSON:**
443
+ #### Playwright JSON (Recommended)
444
+
445
+ ✅ **Updates existing tests** via annotations. Use this format to link results to your existing Xray test cases.
446
+
430
447
  ```bash
431
448
  # Generate JSON report in Playwright
432
449
  npx playwright test --reporter=json > playwright-results.json
433
450
 
434
- # Import to Xray (links to existing tests or creates new ones)
451
+ # Import to Xray (updates existing tests via annotations)
435
452
  npx xqt import-results --file playwright-results.json --testExecKey QE-123
436
453
 
437
454
  # Create new Test Execution automatically
438
455
  npx xqt import-results --file playwright-results.json --summary "Regression Suite"
439
456
  ```
440
457
 
458
+ **Required test code:**
459
+ ```typescript
460
+ import { test, expect } from '@playwright/test';
461
+
462
+ test('Verify API endpoint', async ({ request }) => {
463
+ // THIS LINE links to existing Xray test
464
+ test.info().annotations.push({ type: 'xray', description: 'PROJ-123' });
465
+
466
+ // Your test code...
467
+ });
468
+ ```
469
+
441
470
  | Option | Description | Required |
442
471
  |-----------------------------|---------------------------------------------------|----------|
443
472
  | `--file <path>` | Path to results file (.xml or .json) | Yes |
@@ -449,22 +478,28 @@ npx xqt import-results --file playwright-results.json --summary "Regression Suit
449
478
 
450
479
  **Mapping Playwright Tests to Xray:**
451
480
 
452
- To link Playwright test results to existing Xray test cases, use annotations or include test keys in titles:
481
+ To link Playwright test results to existing Xray test cases, **you must use annotations**:
453
482
 
454
483
  ```typescript
455
- // Option 1: Using annotations (recommended)
484
+ // CORRECT - Updates existing test PROJ-123
456
485
  test('User login flow', async ({ page }) => {
457
486
  test.info().annotations.push({ type: 'xray', description: 'PROJ-123' });
458
487
  // ... test code
459
488
  });
460
489
 
461
- // Option 2: Include test key in title
490
+ // Alternative - Include test key in title
462
491
  test('[PROJ-456] User registration validates email', async ({ page }) => {
463
492
  // ... test code
464
493
  });
494
+
495
+ // ❌ WRONG - Creates new test every time
496
+ test('User login flow', async ({ page }) => {
497
+ // Missing annotation - will create duplicate test!
498
+ // ... test code
499
+ });
465
500
  ```
466
501
 
467
- If no test key is found, a new test will be created in Xray with the test title as the summary.
502
+ **Without annotations:** A new test will be created in Xray with the test title as the summary (not recommended for existing tests).
468
503
 
469
504
  ---
470
505
 
@@ -720,33 +755,176 @@ Use this checklist to align a new team's board and Xray configuration with the t
720
755
  └─────────────────────────────────────────────────────────────────────────┘
721
756
  ```
722
757
 
723
- ### Playwright Integration Workflow
758
+ ## Playwright Quick Start
724
759
 
725
- For teams using Playwright for API or E2E testing:
760
+ ### Complete Setup for Updating Existing Xray Tests
761
+
762
+ This is the **recommended workflow** for teams using Playwright with existing Xray test cases.
763
+
764
+ #### Step 1: Install Playwright (in your test repo)
726
765
 
727
766
  ```bash
728
- # 1. Write Playwright tests with Xray annotations
729
- # tests/login.spec.ts
730
- test('User login with valid credentials', async ({ page }) => {
731
- test.info().annotations.push({ type: 'xray', description: 'PROJ-123' });
732
- // ... test implementation
767
+ npm install --save-dev @playwright/test
768
+ ```
769
+
770
+ #### Step 2: Configure Playwright
771
+
772
+ Create `playwright.config.ts` in your test repo:
773
+
774
+ ```typescript
775
+ import { defineConfig } from '@playwright/test';
776
+
777
+ export default defineConfig({
778
+ reporter: [
779
+ ['html'], // For local viewing
780
+ ['json', { outputFile: 'playwright-results.json' }], // For Xray import
781
+ ],
782
+
783
+ use: {
784
+ baseURL: process.env.API_BASE_URL || 'https://your-api.com',
785
+ extraHTTPHeaders: {
786
+ 'Authorization': `Bearer ${process.env.API_TOKEN}`,
787
+ 'X-API-Key': process.env.API_KEY || '',
788
+ },
789
+ },
733
790
  });
791
+ ```
734
792
 
735
- # 2. Run tests and generate JSON report
736
- npx playwright test --reporter=json > playwright-results.json
793
+ #### Step 3: Write Tests with Xray Annotations
737
794
 
738
- # 3. Import results to Xray (links to existing tests or creates new)
739
- npx xqt import-results --file playwright-results.json --testExecKey PROJ-456
795
+ ⚠️ **Critical:** Every test MUST have an annotation to update existing Xray tests.
740
796
 
741
- # Or create new execution automatically
742
- npx xqt import-results --file playwright-results.json --summary "Playwright Regression"
797
+ ```typescript
798
+ import { test, expect } from '@playwright/test';
799
+
800
+ test.describe('Regression Tests', () => {
801
+
802
+ test('Verify API returns 200 for valid request', async ({ request }) => {
803
+ // THIS LINE links to your existing Xray test
804
+ test.info().annotations.push({ type: 'xray', description: 'APIEE-7131' });
805
+
806
+ const response = await request.post('/api/verify', {
807
+ data: { userId: '123', action: 'validate' }
808
+ });
809
+
810
+ // Attach response as evidence for Xray
811
+ test.info().attach('response-evidence', {
812
+ body: JSON.stringify({
813
+ status: response.status(),
814
+ headers: response.headers(),
815
+ body: await response.json()
816
+ }, null, 2),
817
+ contentType: 'application/json'
818
+ });
819
+
820
+ expect(response.status()).toBe(200);
821
+ });
822
+
823
+ test('Verify API returns 400 for invalid data', async ({ request }) => {
824
+ test.info().annotations.push({ type: 'xray', description: 'APIEE-7132' });
825
+ // ... test implementation
826
+ });
827
+
828
+ });
743
829
  ```
744
830
 
745
- **Benefits:**
746
- - Automatically maps Playwright tests to Xray test cases using annotations or `[TEST-123]` in titles
747
- - Creates new test cases in Xray if no mapping found
748
- - Supports Playwright retries, worker info, and detailed error reporting
749
- - Works in CI/CD pipelines for continuous test reporting
831
+ #### Step 4: Map All Your Tests
832
+
833
+ Based on your `xray-mapping.json`, add annotations to each test:
834
+
835
+ ```typescript
836
+ // If your xray-mapping.json shows:
837
+ // "TC-001": { "key": "APIEE-7131", "id": "1879092" }
838
+ // "TC-002": { "key": "APIEE-7132", "id": "1879095" }
839
+
840
+ test('Test Case 1', async ({ request }) => {
841
+ test.info().annotations.push({ type: 'xray', description: 'APIEE-7131' });
842
+ // ...
843
+ });
844
+
845
+ test('Test Case 2', async ({ request }) => {
846
+ test.info().annotations.push({ type: 'xray', description: 'APIEE-7132' });
847
+ // ...
848
+ });
849
+ ```
850
+
851
+ #### Step 5: Run Locally
852
+
853
+ ```bash
854
+ # Run tests
855
+ npx playwright test
856
+
857
+ # View HTML report
858
+ npx playwright show-report
859
+
860
+ # Upload to Xray (updates existing tests)
861
+ npx xqt import-results --file playwright-results.json --testExecKey APIEE-6811
862
+ ```
863
+
864
+ #### Step 6: Configure CI/CD
865
+
866
+ **Azure Pipelines:**
867
+
868
+ ```yaml
869
+ steps:
870
+ - task: NodeTool@0
871
+ inputs:
872
+ versionSpec: '18.x'
873
+
874
+ - script: npm ci
875
+ displayName: 'Install dependencies'
876
+
877
+ - script: npx playwright test
878
+ displayName: 'Run Playwright tests'
879
+ continueOnError: true
880
+
881
+ - script: |
882
+ npx xqt import-results \
883
+ --file playwright-results.json \
884
+ --testExecKey APIEE-6811
885
+ displayName: 'Upload results to Xray'
886
+ env:
887
+ XRAY_ID: $(XRAY_ID)
888
+ XRAY_SECRET: $(XRAY_SECRET)
889
+ JIRA_PROJECT_KEY: $(JIRA_PROJECT_KEY)
890
+ JIRA_URL: $(JIRA_URL)
891
+ JIRA_API_TOKEN: $(JIRA_API_TOKEN)
892
+ JIRA_EMAIL: $(JIRA_EMAIL)
893
+ ```
894
+
895
+ **GitHub Actions:**
896
+
897
+ ```yaml
898
+ steps:
899
+ - uses: actions/setup-node@v3
900
+ with:
901
+ node-version: '18'
902
+
903
+ - run: npm ci
904
+
905
+ - run: npx playwright test
906
+
907
+ - run: |
908
+ npx xqt import-results \
909
+ --file playwright-results.json \
910
+ --testExecKey APIEE-6811
911
+ env:
912
+ XRAY_ID: ${{ secrets.XRAY_ID }}
913
+ XRAY_SECRET: ${{ secrets.XRAY_SECRET }}
914
+ JIRA_PROJECT_KEY: ${{ secrets.JIRA_PROJECT_KEY }}
915
+ JIRA_URL: ${{ secrets.JIRA_URL }}
916
+ JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
917
+ JIRA_EMAIL: ${{ secrets.JIRA_EMAIL }}
918
+ ```
919
+
920
+ ### Benefits
921
+
922
+ ✅ **Updates existing tests** - No duplicate test creation
923
+ ✅ **Automatic mapping** - Via annotations in test code
924
+ ✅ **Evidence attachments** - Screenshots, responses, traces
925
+ ✅ **Detailed reporting** - Retries, worker info, error details
926
+ ✅ **CI/CD ready** - Standard workflow for automation
927
+ ✅ **Single source of truth** - Test code + Xray together
750
928
 
751
929
  ---
752
930
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@msalaam/xray-qe-toolkit",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Full QE workflow toolkit for Xray Cloud integration — test management, Postman generation, CI pipeline scaffolding, and browser-based review gates for API regression projects.",
5
5
  "type": "module",
6
6
  "bin": {