Code Monkey home page Code Monkey logo

check-tests's Introduction

๐ŸŒ€ AutoCheck Tests by Testomatio

GitHub Action with Static Analysis for your JavaScript tests.

This action shows changed tests on each pull request with a complete list of all tests in this project. You can create test document in wiki of the project.

Use this checker as

Features

  • Analyzes JavaScript test files in Pull Request
  • Uses AST parser to analyze tests
  • Detects added, removed, skipped tests
  • Fails when finds .only exclusive tests
  • Adds labels for PR with or witout tests
  • Shows expressive report for each PR
  • TypeScript supported

GitHub Action

Sample Report


๐ŸŒ€ Tests overview by Testomatio

Found 7 codeceptjs tests in 1 files

โœ”๏ธ Added 1 test

+ @first Create Todos @step:06 @smoke @story:12345: Another test

โš ๏ธ Skipped 1 test

- @first Create Todos @step:06 @smoke @story:12345: Create multiple todo items
๐Ÿ“‘ List all tests

๐Ÿ“Ž @first Create Todos @step:06 @smoke @story:12345

๐Ÿ“ todomvc-tests/create-todos_test.js

tests


Usage

Once this action is enabled, bot will create a comment for each Pull Request with a list of all changed tests.

This information is useful to:

  • track addition and removal of tests
  • protect from skipping tests
  • protect from using .only exclusive tests
  • automatically mark PR with has tests or no tests labels
  • review tests on GitHub

Installation

Check that your project uses one of the following testing frameworks (this list will be extended).

Supported testing frameworks

  • mocha
  • codeceptjs
  • cypress.io
  • jest
  • protractor
  • jasmine
  • testcafe

Add this action to your workflow file .github/workflow/main.yml and configure.

on: [push]

jobs:
  test:
    runs-on: ubuntu-latest
    name: Check Tests
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - uses: testomatio/check-tests@stable
        with:
          framework: # REQUIRED - testing framework
          tests: # REQUIRED - glob pattern to match test files
          token: ${{ secrets.GITHUB_TOKEN }}

It is important to enable actions/checkout@v2 step with fetch-depth: 0 to allow testomatio to compare tests in pull requests with tests in base.

Inputs (Configuration)

  • framework - (required) Test framework to be used. Supported: mocha, codeceptjs'
  • tests - (required) Glob pattern to match tests in a project, example: tests/**_test.js'
  • token - (should be: ${{ secrets.GITHUB_TOKEN }}) GitHub token to post comment with summary to current pull request
  • typescript - enable TypeScript support
  • has-tests-label - add a label when PR contains new tests. Set true or a label name to enable.
  • no-tests-label - add a label when PR contains no new tests. Set true or a label name to enable.
  • comment-on-empty - post a comment to PR when no tests added. Can be either boolean (for neutral message) or a custom message within a comment (markdown supported)
  • close-on-empty - close PR when no tests added. Use with comment-on-empty to clarify this action
  • comment-on-skipped - add custom message when new tests are skipped (markdown supported).
  • close-on-skipped - close PR when introduced skipped tests. Use with comment-on-skipped to clarify this action
  • enable-documentation - If set to true, test document will be created in wiki.
  • wiki-doc-name - Name of the wiki document. By default it will use Test Document
  • documentation-branch - Branch to create document on push. Uses default branch if this field is empty
  • github-pat - Github Private access token to create document in wiki.

Examples

For creating test document

This example uses jest as example. Tests are located in tests/ directory. You can generate GH_PAT here and add the generated token in secrets of your repo.

If documentation branch is not provided, it will consider default branch of the repo.

steps:
  - uses: actions/checkout@v2
    with:
      fetch-depth: 0
  - uses: actions/setup-node@v1
    with:
      node-version: '12'
  - run: npm install
  - uses: testomatio/check-tests@stable
    with:
      framework: jest
      tests: 'tests/*.spec.js'
      token: ${{ secrets.GITHUB_TOKEN }}
      github-pat: ${{ secrets.GH_PAT }}
      enable-documentation: true
      wiki-doc-name: 'Test-Document'
      documentation-branch: 'doc-branch'

Jest

Jest tests located in tests/ directory:

steps:
  - uses: actions/checkout@v2
    with:
      fetch-depth: 0
  - uses: testomatio/check-tests@stable
    with:
      framework: jest
      tests: tests/**.spec.js
      token: ${{ secrets.GITHUB_TOKEN }}
      comment-on-empty: true
      has-tests-label: true
  • list all tests even no tests were added
  • add label if tests were added

Cypress.io

Cypress.io tests located in cypress/integration directory:

steps:
  - uses: actions/checkout@v2
    with:
      fetch-depth: 0
  - uses: testomatio/check-tests@stable
    with:
      framework: cypress.io
      tests: cypress/integration/**.js
      token: ${{ secrets.GITHUB_TOKEN }}
      comment-on-empty: true
      has-tests-label: true
  • list all tests even no tests were added
  • add label if tests were added

CodeceptJS

CodeceptJS tests located in tests directory:

steps:
  - uses: actions/checkout@v2
    with:
      fetch-depth: 0
  - uses: testomatio/check-tests@stable
    with:
      framework: codeceptjs
      tests: tests/**_test.js
      token: ${{ secrets.GITHUB_TOKEN }}
      comment-on-empty: true
      has-tests-label: true
  • list all tests even no tests were added
  • add label if tests were added

Protractor

Protractor tests located in spec directory:

steps:
  - uses: actions/checkout@v2
    with:
      fetch-depth: 0
  - uses: testomatio/check-tests@stable
    with:
      framework: protractor
      tests: spec/**.spec.js
      token: ${{ secrets.GITHUB_TOKEN }}
      comment-on-empty: true
      has-tests-label: true
  • list all tests even no tests were added
  • add label if tests were added

Protractor with TypeScript

Protractor tests located in spec directory:

steps:
  - uses: actions/checkout@v2
    with:
      fetch-depth: 0
  - uses: testomatio/check-tests@stable
    with:
      framework: protractor
      tests: spec/**.spec.ts
      token: ${{ secrets.GITHUB_TOKEN }}
      typescript: true

Mocha

Mocha tests located in tests/ directory:

steps:
  - uses: actions/checkout@v2
    with:
      fetch-depth: 0
  - uses: testomatio/check-tests@stable
    with:
      framework: mocha
      tests: tests/**_test.js
      token: ${{ secrets.GITHUB_TOKEN }}
      no-tests-label: Tests Needed

Testcafe

Testcafe tests located in tests/ directory:

steps:
  - uses: actions/checkout@v2
    with:
      fetch-depth: 0
  - uses: testomatio/check-tests@stable
    with:
      framework: testcafe
      tests: tests/**/*.js
      token: ${{ secrets.GITHUB_TOKEN }}
      no-tests-label: Tests Needed

Newman

TESTOMATIO={apiKey} npx check-tests newman "your_collection_name.json"

or

TESTOMATIO={apiKey} npx check-tests newman "folder_with_collections/*.json"

Close PRs without tests

When PR doesn't contain tests - close it and write a message

steps:
  - uses: actions/checkout@v2
    with:
      fetch-depth: 0
  - uses: testomatio/check-tests@stable
    with:
      framework: protractor
      tests: spec/**_spec.js
      token: ${{ secrets.GITHUB_TOKEN }}
      comment-on-empty: '## PRs without tests not allowed'
      close-on-empty: true

Notify on skipped tests

When PR contains skipped tests - close it and write a message

steps:
  - uses: actions/checkout@v2
    with:
      fetch-depth: 0
  - uses: testomatio/check-tests@stable
    with:
      framework: protractor
      tests: spec/**_spec.js
      token: ${{ secrets.GITHUB_TOKEN }}
      comment-on-skipped: "## Don't mark tests as skipped!"
      close-on-skipped: true

CLI

Use this checker as CLI tool with any Continuous Integration service.

Run check-tests via npx:

npx check-tests <framework> "<tests>" --no-skipped

Development

To change host of endpoint for receiving data, and set it to other than app.testomat.io use TESTOMATIO_URL environment variable:

TESTOMATIO_URL=http://local.testomat.io

This checker will fail a build if exclusive tests (with .only or fit or fdescribe found)

Arguments:

  • test framework
  • glob pattern to match tests in a project, example: tests/**_test.js'. It is important to include glob pattern in double quotes " so wildcard could be used correctly.

CLI Options:

  • --no-skipped - fail when skipped tests found
  • --typescript - enable typescript support
  • -g, --generate-file <fileName> - Export test details to document
  • -u, --url <url>, Github URL to get file link (URL/tree/master)

Example

Check tests for CodeceptJS

npx check-tests codeceptjs "tests/**_test.js"

Check tests for Protractor

npx check-tests protractor "spec/**.spec.js"

Check tests for Protractor with TypeScript

npx check-tests protractor "spec/**.spec.ts" --typescript

Check tests for Cypress.io

npx check-tests cypress "cypress/integration/**.js"

Check tests for Testcafe

npx check-tests testcafe "tests/**.js"

Sample Output

List CodeceptJS tests

When found .only test:

โœ— npx check-tests mocha "test/**/**_test.js"

[[ Tests checker by testomat.io ]]
Error: Exclusive tests detected. `.only` call found in test/checkout/important_test.js:290
Remove `.only` to restore test checks

Using in Testomatio

This library is used by Testomatio to import tests.

Importing Into Project

Use TESTOMATIO environment variable with a valid API key to import data into a project. API key can be obtained on project settings page or on "Import From Source" page.

For example:

TESTOMATIO=11111111 npx check-tests CodeceptJS "**/*{.,_}{test,spec}.js"

Test code

By default, check-test sends the code of the test hooks to the "client": before, beforeEach and after. In the "Codes" section you can see all the additional "context" of the test (Testomat.io).

To exclude hook code from a client test, use the --no-hooks option

TESTOMATIO=11111111 npx check-tests CodeceptJS "**/*{.,_}{test,spec}.js" --no-hooks

Additional line number to the test code

To include line number code from a client test, use --line-numbers option. (By default Code section exclude "line number")

TESTOMATIO=11111111 npx check-tests CodeceptJS "**/*{.,_}{test,spec}.js" --line-numbers

Import Parametrized Tests

It is possible to import parametrized tests if they use template literals with variables in thier names:

['one', 'two', 'three'].forEach(() => {
  it(`this is test number ${parameter}`);
});

This test will be imported with its original name including a placeholder:

this is test number ${parameter}

When executed test will be reported with 3 results matched to the same test and param values will be added to the report.

Disable Detached Tests

If a test from a previous import was not found on next import it is marked as "detached". This is done to ensure that deleted tests are not staying in Testomatio while deleted in codebase.

To disable this behavior and don't mark anything on detached on import use --no-detached option

TESTOMATIO=11111111 npx check-tests CodeceptJS "**/*{.,_}{test,spec}.js" --no-detached

This option could also be set via environment variable TESTOMATIO_NO_DETACHED=1. If you don't want to pass it each time, create .env file in the root dir of your project with this variable set.

Synchronous Import

By default check-tests doesn't wait for all tests to be processed. It sends request to Testomatio and exits. To wait for processing to finish use --sync option.

TESTOMATIO=11111111 npx check-tests CodeceptJS "**/*{.,_}{test,spec}.js" --sync

Please note, that this will take a long time on a large codebase.

Auto-assign Test IDs in Source Code

To disable guess matching for tests it is recommend to use Testomatio IDs to map a test in source code to a test in Testomatio. Testomatio IDs can be put automatically into the test names into source code when --update-ids option is used:

TESTOMATIO=11111111 npx check-tests CodeceptJS "**/*{.,_}{test,spec}.js" --update-ids

Tests imported with --update-ids will be processed in synchronouse mode, so the script will finish after all tests are processed.

Keep Test IDs Between Projects

To import tests with Test IDs set in source code into another project use --create option. In this case, a new project will be populated with the same Test IDs.

TESTOMATIO=11111111 npx check-tests CodeceptJS "**/*{.,_}{test,spec}.js" --create

Without --create import will fail with a message that ID was not found.

Clean Test IDs

If you want to import the synced project as new project, you have to clean the test ids. To clean up test ids without connecting to Testomatio project use --purge option:

npx check-tests CodeceptJS "**/*{.,_}{test,spec}.js" --purge

This method may be unsafe, as it cleans all @S* and @T* tags from tests and suites. So if you have a tag like @Test1234 this may also be removed. If you use this option make sure if all the test titles a proper before committing the tests in GIT.

Note: --purge is an alias of --unsafe-clean-ids option.

To clean only test ids set from a specific project use --clean-ids option instead:

TESTOMATIO=11111111 npx check-tests CodeceptJS "**/*{.,_}{test,spec}.js" --clean-ids

TESTOMATIO is API key of a project with existing test ids.

Import Into a Branch

Tests can be imported into a specific branch if TESTOMATIO_BRANCH parameter is used. Branch is matched by its id. If branch was not found, it will be created.

TESTOMATIO_BRANCH=dev TESTOMATIO=1111111 npx check-tests CodeceptJS "**/*{.,_}{test,spec}.js"

Keep Structure of Source Code

When tests in source code have IDs assigned and those tests are imported, Testomat.io uses current structure in a project to put the tests in. If folders in source code doesn't match folders in Testomat.io project, existing structure in source code will be ignored. To force using the structure from the source code, use --keep-structure flag on import:

TESTOMATIO=1111111 npx check-tests CodeceptJS "**/*{.,_}{test,spec}.js" --keep-structure

Delete Empty Suites

If tests were marked with IDs and imported to already created suites in Testomat.io newly imported suites may become empty. Use --no-empty option to clean them up after import.

TESTOMATIO=1111111 npx check-tests CodeceptJS "**/*{.,_}{test,spec}.js" --no-empty

This prevents usage --keep-structure option.

Import Into a Specific Suite

To put all imported tests into a specific suite (folder) pass in TESTOMATIO_PREPEND_DIR environment variable:

TESTOMATIO_PREPEND_DIR="MyTESTS" TESTOMATIO=1111111 npx check-tests CodeceptJS "**/*{.,_}{test,spec}.js"

TypeScript

For TypeScript projects @babel/core and @babel/plugin-transform-typescript packages are used. GitHub Action already contains those modules, while CLI version of this tool tries to automatically install them on first run.

If you face issues parsing TypeScript file menitioning @babel/core or @babel/plugin-transform-typescript try to install them manually:

npm i @babel/core @babel/plugin-transform-typescript --save-dev

Now tests TypeScript can be imported with --typescript option:

TESTOMATIO=11111111 npx check-tests CodeceptJS "**/*{.,_}{test,spec}.js" --typescript

Programmatic API

Import Analyzer from module:

const { Analyzer } = require('check-tests');

const framework = 'jest';
const pathToTests = './tests';
const pattern = '**/*[._-]{test,spec}.{ts,js}';

const analyzer = new Analyzer(framework, pathToTests);

// to enable typescript...
analyzer.withTypeScript();

// to enable babel plugins
analyzer.addPlugin('@babel/plugin-syntax-jsx');
analyzer.addPlugin('@babel/plugin-syntax-flow');

// to enable babel presets
analyzer.addPreset('@babel/preset-react');
analyzer.addPreset('@babel/preset-flow');

analyzer.analyze(pattern);

// stats on processed files
const stats = analyzer.stats;

// full info on parsed tests
const data = analyzer.rawTests;

Debugging

Run import with DEBUG="testomatio:*" environment variable to get additional logs which may help understanding the cause of an issue. Usually it may happen because of a specific file that couldn't be parsed:

DEBUG="testomatio:*" npx check-tests@latest ....

API Definition

API Endpoint to import test data into Testomat.io:

Import API Reference

Limitations

  • Can't analyze included tests from external files
  • Can't analyze dynamically created tests

License MIT

Part of Testomat.io

check-tests's People

Contributors

davertmik avatar dependabot[bot] avatar kmkoushik avatar kobenguyent avatar mykhailiukvitalii avatar olexandr13 avatar poliarush avatar vkeyboardv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

check-tests's Issues

One-to-many test mapping

Is your feature request related to a problem? Please describe.
Some of our automation tests fulfill the requirements of several test case ID's from our test management system. Currently it seems only one-to-one mapping exists between a single automation test and single test case that is imported or created in testomatio

Describe the solution you'd like
The ability to map a single automation test to multiple test cases.

Describe alternatives you've considered
Rewriting automation tests to be one to one, however with 1k+ tests, it could take considerable time.

Additional context
In a framework like Playwright, we have the ability to create a test which includes several test.step methods. It might be helpful if we can identify which portion of the test applies to individual test cases. From my understanding, most frameworks offer the ability have soft assertions which continue on the test if one step fails. Currently, we have multiple test cases tied to a single automation test setup as follows however:

        test.describe("Add/Edit user (parallel)", () => {
            for (const role of roles1) {
                baseTest.describe(`[C88, C81641, C8209, C8199, C43080, C45741]: ${role.groupName}`, () => {
                    baseTest.use({ storageState: `${role.storageStatePath}` });
    
                    baseTest(`Add new Worker`, async ({ userPage, random, apiRequest, common, request }) => {
                        await apiRequest.createAgency(request, random.agencyName);
                        const officeID = await apiRequest.createBillingOffice(request, random.officeName);
                        const campusID = await apiRequest.createCampus(request, random.campusName);
                        await apiRequest.createFacility(request, random.facilityName, random.rand, officeID, campusID);
                        await Promise.all([
                            userPage.page.goto(`${process.env.BASE_URL}admin`),
                            userPage.page.waitForResponse(resp => resp.url().includes('api/v1/users/table') && resp.status() == 200)
                        ])
                        await userPage.usersPO.openAddUserPage();
                        await userPage.addEditUserPO.addWorker(random.userEmail, random.userPhoneNumber, random.facilityName, random.agencyName, role.groupName);
                        await common.goToUsersPage();
                        await userPage.usersPO.verifyTheUserExist(random.userEmail);
                        await userPage.usersPO.openFirstUserPage();
                        await expect(userPage.addEditUserPO.submittionStatusButton).toContainText('accepted');
                        await userPage.addEditUserPO.verifyWorkerInfo(random.userEmail, random.userPhoneNumber, random.facilityName, random.agencyName, role.groupName);
                    })
                })
           }

This approach is less ideal but what we're currently using.

Add support for it.each tests in Jest

Support for data driven tests in Jest.

Jest has test.each syntax which can generate multiple test cases at once. We need to support it in our parser to handle such cases.

Jest parser should be updated to handle test.each as tests.
As a reference take similar syntax from CodeceptJS

// in Jest
test.each([1,2])()

// in CodeceptJS
Data([1,2]).Scenario()

Here is the implementation from CodeceptJS
https://github.com/testomatio/check-tests/blob/master/lib/frameworks/codeceptjs.js#L72

Implement a similar thing for Jest parser as well.
https://github.com/testomatio/check-tests/blob/master/lib/frameworks/jest.js

Unit test for test.each case should also be added here https://github.com/testomatio/check-tests/blob/master/tests/jest_test.js

[Playwright/Typescript] update-ids func inserts ids into import statements

When I use typescript path aliases, updatei-ids doesn't work as expected. It inserts the suiteId on the first line that matches the describe title. In this case it's "Shift"

import {expect, Page, test} from '@playwright/test'
import Shift @Sff4de22bModel from '@src/models/ShiftModel'

test.describe('Shift', () => {

Parameter in parameterised test incorrectly parsed on API side

Describe the bug
Testomatio API incorrectly parse parameterised test value

To Reproduce
Execute parameterised test
Ex. request to API

{
  'artifacts': [],
   'code': None,
   'example': None,
   'message': None,
   'run_time': 0.7919288370176218,
   'stack': None,
   'status': None,
   'steps': None,
   'suite_id': None,
   'suite_title': 'test_local_file_operations_via_cli.py',
   'test_id': 'f30bd3b0',
   'title': 'Version 1.0.0 @Tf30bd3b0'
}

Expected behavior
Test is displayed in test run with 1.0.0 parameter

Actual behaviour
Test is displayed in test run with 1 parameter

Screenshots
image
image

Script to update test ids doesn't work

The script that we use to update the test ids does not add new test ids for added test scenarios

Script: TESTOMATIO=b0f2514004q7 npx check-tests@latest CodeceptJS "**/*{.,_}{test,spec}.ts" --typescript --update-ids

Example file

More info on this slack thread.

0 tests is not valid output




TOTAL 0 TESTS FOUND


 ๐Ÿš€ Sending data to testomat.io

 ๐ŸŽ‰ Data sent to Testomat.io

0 tests - there is nothing to send to testomatio.

The message should be like this:

Can't find any tests in this folder.
Change file pattern or directory to scan to find test files:

Usage: npx check-tests <pattern> -d [directory]

Getting incorrect suite name when using serial notation

I have this suite notation to run tests on serial mode:

test.describe.serial("Subscriptions page feature tests", {tag: ['@subs']}, async () => {

When suite is imported from Testomat, it doesn't get the suite name and uses the file name (it's the second one):

image

Note:
If I use this configuration:
test.describe.configure({ mode: 'serial' });

Suite is imported properly.

Note 2:
Also with parallel notation is working properly:

test.describe.parallel("Login page feature tests", {tag: ['@loginUser']}, async () => {

Language: Typescript
Framework: Playwright

Python RobotFramework integration

  • auto assign ids from testomat
  • manual ids assignment
  • sync with testomat.io

Support following actions:

  • Importing Into Project
  • Disable Detached Tests
  • Synchronous Import
  • Auto-assign Test IDs in Source Code
  • Keep Test IDs Between Projects
  • Clean Test IDs
  • Import Into a Branch
  • Keep Structure of Source Code
  • Delete Empty Suites
  • Import Into a Specific Suite

Update Playwright tags parsing

Is your feature request related to a problem? Please describe.

Playwrigh has new tags format. Need to update check-tests to import tags correctly to Testomat.

telegram-cloud-photo-size-2-5400026170847779021-y

Check-tests v 0.8.5 shows warning for current project

To Reproduce

  1. import tests with check-tests v 0.8.5 with --update-ids to Testomat project
  2. import tests with check-tests v 0.8.5 with --update-ids again to the project
  3. see warning in terminal:
    ! Previously set Test IDs detected, new IDs ignored
    ! Clean previously set Test IDs to override them
    ! Run script with DEBUG="testomatio:*" flag to get more info of affected tests
    0 files updated.

CleanShot 2023-02-22 at 14 24 21@2x

Generate Living Documentation as Markdown file

Add to check-tests CLI a command which will generate documentation in Markdown format:

npx check-tests CodeceptJS **.test --doc tests.md

This will create tests.md file and write into it all found tests.

This feature is already available as GitHub Action, it also pushes generated markdown to GitHub Wiki. But we need that this option to exist in CLI and generate a simple md file which can be used as documentation in GitHub repo or on statice website, etc.

Documentation Generator: https://github.com/testomatio/check-tests/blob/master/src/document.js

Error parsing {some test file}: SyntaxError: Unexpected token (42:9)

I'm running the command TESTOMATIO={the_project_key} npx check-tests@latest Jest "**/*{.,_}{test,spec}.js" -d src/tests.

The command manages to find only one valid test.

All other tests fail, apparently because the command does not understand JSX.

Here are a few examples where the checker throws the error:

	it('has import now button', () => {
		const button_text = 'Push me!';
		render(<App buttonText={button_text}/>);
		expect(button()).not.toBeNull();
		expect(button().textContent).toEqual(button_text);
	});
describe('Items to scan UI', () => {
	const items = ['plugin1', 'plugin2'];
	let onSelected;
	const render = () => shallow(<ItemsToScan heading={'heading'} items={items} onSelected={onSelected}/>);

	beforeEach(() => {
		onSelected = jest.fn();
	});
describe('MO Scan on Localization page', () => {

	it('creates app', () => {
		const fileCount = 10;
		const filesToScan = {
			count: fileCount,
			plugins: ['plugin1'],
			themes: [],
			other: []
		};
		const expectedTitle = "WPML has detected changed or new MO files";

		const wrapper = shallow(
			<MOScanUILocalizationPage filesToScan={filesToScan}/>
		);

In all cases, it fails when it encounters some JSX (<App buttonText={button_text}/>, <ItemsToScan, <MOScanUILocalizationPage).

I don't know if that's a known limitation (from the docs, it doesn't look like it is) and how I can get around it.

Running Jest, of course, works without problems, as these are tests we have for a few years already.

I can share the source code if needed, but with other more private means, as it's from a commercial product.

--no-empty option seems to be ignored on backend

Describe the bug
There seems to be a no way to get rid of empty test suites

To Reproduce
I have tried to import test with both options

Screenshot 2023-09-29 at 18 10 46 Screenshot 2023-09-29 at 18 09 18

After import - empty suite remains available
image

Expected behavior
When noempty is sent as true - Testomatio removes empty suites

GH report error if create PR from fork

https://github.com/testomatio/check-tests/pull/83/checks

Error: Resource not accessible by integration
RequestError [HttpError]: Resource not accessible by integration
    at /home/runner/work/_actions/testomatio/check-tests/stable/node_modules/@octokit/request/dist-node/index.js:66:23
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async run (/home/runner/work/_actions/testomatio/check-tests/stable/index.js:119:7) {
  status: 403,

`stable` branch not updated since Sep 2021

This follows on from issue #79 "stable branch gives Node.js 12 deprecation warning".

The stable branch recommended in the README documentation is unchanged since commit 0ea638f of @DavertMik on Sep 25, 2021.

See stable...master

If fixes and features are added to the default master branch, they will not be used by GitHub workflows such as .github/workflows/main.yml in this repository.

- uses: testomatio/check-tests@stable

This can be seen in the "Set up job" job for instance in job 8219074452

Download action repository 'testomatio/check-tests@stable' (SHA:0ea638fcec1820cf2e7b9854fdbdd04128a55bd4)

from the full job log

Current runner version: '2.303.0'
Operating System
Runner Image
Runner Image Provisioner
GITHUB_TOKEN Permissions
Secret source: None
Prepare workflow directory
Prepare all required actions
Getting action download info
Download action repository 'actions/checkout@v1' (SHA:50fbc622fc4ef5163becd7fab6573eac35f8462e)
Download action repository 'actions/setup-node@v2' (SHA:1f8c6b94b26d0feae1e387ca63ccbdc44d27b561)
Download action repository 'testomatio/check-tests@stable' (SHA:0ea638fcec1820cf2e7b9854fdbdd04128a55bd4)
Complete job name: Check Tests

Suggestion

Merge the latest release 0.8.12 into the stable branch.

Add "--line-numbers" option to check-test npm command

Add "--line-numbers" option to check-test npm command.
Example:
[without mode]

 Scenario('Edited todo is saved', async (I, TodosPage) => {
  I.say('Given I have some todos');\n" +
});

[with mode]

10: Scenario('Edited todo is saved', async (I, TodosPage) => {
11:  I.say('Given I have some todos');\n" +
12: });

avoid "node_modules" while scanning directory

In Import instructions on website we provide a very wide pattern for files to scan and it appears that tests from "node_modules" folder are added to output.

Please check the path of scanned tests.
If path contains node_modules directory - ignore that test.

Fix TypeScript support (--update-ids option)

Auto-assign Test IDs with --typescript option reformat code and cut out typings in test.

ENV: TS, Jest

STR:

  1. In __tests__ folder create new file eg.test.ts
  2. Add code:
const isEven = (n: number): boolean => n % 2 === 0;

const cases: Array<[number, boolean]> = [
    [2, true],
    [0, true],
    [1, false],
    [-2, true],
    [-1, false],
    [Math.PI, false],
    [50, true],
    [75, false]
]

describe('Check if number is even', () => {
    it.each(cases)('The %d is even %p', (number, expected ) => {
        expect(isEven(number)).toBe(expected)
    })
})
  1. Run update ids command
check-tests --typescript Jest "__tests__/*{.,_}{test,spec}.ts" --update-ids

AR:

  1. Code had reformatted
  2. Typings had removed
const isEven = (n) => n % 2 === 0;
const cases = [[2, true], [0, true], [1, false], [-2, true], [-1, false], [Math.PI, false], [50, true], [75, false]];
describe('Check if number is even @S298ffaa1', () => {
  it.each(cases)('The %d is even %p', (number, expected) => {
    expect(isEven(number)).toBe(expected);
  });
});

ER:

const isEven = (n: number): boolean => n % 2 === 0;

const cases: Array<[number, boolean]> = [
    [2, true],
    [0, true],
    [1, false],
    [-2, true],
    [-1, false],
    [Math.PI, false],
    [50, true],
    [75, false]
]

describe('Check if number is even @S298ffaa1', () => {
    it.each(cases)('The %d is even %p', (number, expected ) => {
        expect(isEven(number)).toBe(expected)
    })
})

Improve the support for it.each tests in Jest

After test.each support was added (#35) the new problem appeared. If the file has a test.each construction it will upload as one test with template string as name. This situation makes problems with runs because such type of test can't be matched on the platform.
The test parser should add every test from test.each construction as a separate test with the right ID

Playwright automated tests are not being linked with manual tests with the same name

Describe the bug
Upon importing automated tests from Playwright to the project with manual tests with the same names as auto tests, it can be noticed that the manual and automated tests do not match the corresponding manual tests.

To Reproduce
Steps to reproduce the behavior:

  1. Create a classic project with a manual test with a set name
  2. Import Playwright test with the same name

Expected behavior
Manual and automated test cases merge

Actual behavior
Tests stay separated

Desktop (please complete the following information):

  • OS: macOS 13.5.2 (22G91)
  • Browser Chrome
  • Browser Version 116.0.5845.187
  • Application: production

Java TestNG & Junit integration

  • auto assign ids from testomat
  • manual ids assignment
  • sync with testomat.io

Support following actions:

  • Importing Into Project
  • Disable Detached Tests
  • Synchronous Import
  • Auto-assign Test IDs in Source Code
  • Keep Test IDs Between Projects
  • Clean Test IDs
  • Import Into a Branch
  • Keep Structure of Source Code
  • Delete Empty Suites
  • Import Into a Specific Suite

let's allow ignoring test suite without a tag reference

Is your feature request related to a problem? Please describe.
when we try to upload the test XML report then all test suits will be uploaded and an appropriate folder will be created even if there are no test suits tag references in the test suits name

Describe the solution you'd like
would be great to ignore test suits without @ tag references in the name

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

tests with dynamic parameters are not uploaded correctly

Describe the bug
tests with dynamic parameters are not uploaded correctly

To Reproduce
Steps to reproduce the behavior:
Create a test of below format

test.describe('New Loan Application', () => {
    const provinces = ['AB', 'BC', 'MB', 'NB', 'NL', 'NS', 'ON', 'SK'];
    provinces.forEach((state) => {
        test(`Validate New Loan Application for Specific Province ${state} @canpre`, async ({

Expected behavior
Should read the dynamic parameters and upload the tests

Screenshots
Screenshot 2023-11-07 at 4 13 17 PM

Screenshot 2023-11-07 at 4 17 13 PM

stable branch gives Node.js 12 deprecation warning

With - uses: testomatio/check-tests@stable, as documented in the README.md, GitHub issues a deprecation warning:

"Node.js 12 actions are deprecated. Please update the following actions to use Node.js 16: testomatio/check-tests@stable. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/."

check-tests/action.yml

Lines 48 to 50 in 0ea638f

runs:
using: 'node12'
main: 'index.js'

  1. What is the current recommendation for using this action? - uses: testomatio/check-tests@???
  2. Will this JavaScript action be migrated to use node16?

0 tests for invalid framework name

If I provide non-lowercased framework name check-tests reports to find 0 test cases:

โžœ  TESTOMATIO={xxx} npx check-tests codeceptJS "**/**_test.js" -d todomvc-tests
 ๐Ÿคฉ Tests checker by testomat.io

SHOWING CODECEPTJS TESTS FROM **/**_test.js:



TOTAL 0 TESTS FOUND


 ๐Ÿš€ Sending data to testomat.io

Once I change this to codeceptjs it is fine.


  • It should lowercase the framework name and search for it
  • If 0 tests is found it should show proper message and probably exit with 1 code

check-tests fails on the CI with Prepend_dir and Update_ids

Trace below-

Generating script.
Script contents:
TESTOMATIO_PREPEND_DIR="Cash Money" TESTOMATIO=* npx check-tests@latest Playwright "**/*{.,_}{test,spec,cy}.ts" --typescript  --purge --no-detached --keep-structure --update-ids --sync --create
========================== Starting Command Output ===========================
/usr/bin/bash --noprofile --norc /usr/local/azuredevopsagent/_work/_temp/9f550b77-aa0e-4b26-89b7-9feeed724d36.sh
 ๐Ÿคฉ Tests checker by Testomat.io v0.8.19
Error: ENOENT: no such file or directory, open '/usr/local/azuredevopsagent/_work/1/s/tests/Capo.UI.Testing/Cash Money/tests/acquisition/loan-application.spec.ts'
Error: ENOENT: no such file or directory, open '/usr/local/azuredevopsagent/_work/1/s/tests/Capo.UI.Testing/Cash Money/tests/acquisition/loan-application.spec.ts'
    at Object.openSync (node:fs:589:3)
    at Object.readFileSync (node:fs:457:35)
    at cleanIdsCommon (/home/azureagent/.npm/_npx/876480043fc67df8/node_modules/check-tests/src/updateIds/updateIds.js:121:26)
    at cleanIds (/home/azureagent/.npm/_npx/876480043fc67df8/node_modules/check-tests/src/updateIds/index.js:11:10)
    at Command.<anonymous> (/home/azureagent/.npm/_npx/876480043fc67df8/node_modules/check-tests/bin/check.js:89:23)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
##[error]Bash exited with code '1'.
Finishing: Upload Playwright tests

[Playwright/Typescript] Last suiteId has been inserted for each describe with the same title

In my current project, I have quite complex functionality that requires many tests with complex preconditions and actions. In order not to have test files for several thousand lines and 100 tests, I break such tests into files, but leave the same "describe/title" for all describes in each file.

They are normally imported to testomat. The problem occurs when I want to call update-ids.

Let's say I have test files shifts1.spec.ts, shifts2.spec.ts, shifts3.spec.ts. I have imported suites and it has the following structure in Testomat

  • Shifts @S1 shifts1.spec.ts
    • With detailed capacity @S1a
  • Shifts @S2 shifts2.spec.ts
    • Without detailed capacity @S2a
  • Shifts @S3 shifts3.spec.ts
    • Extra @S3a

When I call npx check-tests@latest Playwright ....... --update-ids
@S3 suiteId will be inserted into each file's root describe and child suites will not be mapped/inserted.

How to make Manual Run use CI configuration

I tried to run a CodeceptJS scenario as a Manual Run on Testomat.io but it failed, as it tried to use the default configuration in ./codecept.conf.js which defines localhost.

Expected behavior:

The test should use codecept.ci.conf.js which defines a publicly available live URL of my production server.

Python py.test integration

  • auto assign ids from testomat
  • manual ids assignment
  • sync with testomat.io

Support following actions:

  • Importing Into Project
  • Disable Detached Tests
  • Synchronous Import
  • Auto-assign Test IDs in Source Code
  • Keep Test IDs Between Projects
  • Clean Test IDs
  • Import Into a Branch
  • Keep Structure of Source Code
  • Delete Empty Suites
  • Import Into a Specific Suite

String concatenation in test titles

Users should use string literals instead of + in test titles:

BAD                                           GOOD
'test' + id + ' very important' => `test ${id} important`
  • Docs to use string literals instead (Most top, in Requirements)
  • Try to detect concatenation (or any extra things except string or string literal)

Add an option to exclude one test from synchronization

Is your feature request related to a problem? Please describe.
Synchronized the test suite. But then I want to exclude one test from the set of tests that are synchronized.

Describe the solution you'd like
Enter a command in the console with the name of the test that I want to exclude from synchronization.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.