Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix adding IDs to the tests #186

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Conversation

AZANIR
Copy link
Contributor

@AZANIR AZANIR commented Sep 23, 2024

This MR fixes the functionality for adding unique IDs not only to all tests but also to test suites. The ID generation has been corrected to ensure proper assignment to both tests and suites.

testomatio/app#954

Changes:
Fixed the logic for assigning unique IDs to tests and suites.

Copy link

🌀 Tests overview by Testomatio

Found 128 mocha tests in 16 files

✔️ Added 128 tests

+ analyzer: can import analyzer from main index
+ analyzer: should parse all mocha files
+ analyzer: should parse all typescript files
+ analyzer: should exclude dir in file name if dir specified
+ analyzer: should include full dir in file name
+ analyzer: should avoid node_modules
+ analyzer: should read ` char
+ analyzer: should not load dirs as files
+ analyzer: env variable params: should prepend a dir from env variable
+ codeceptjs parser: create todo tests: should parse codecept file
+ codeceptjs parser: create todo tests: should include code
+ codeceptjs parser: Parse CodeceptJS tags: should include tags
+ codeceptjs parser: Parse CodeceptJS tags & datatable: should include data and tags
+ codeceptjs parser: Parse CodeceptJS hooks code - default opts: should include Before hook code
+ codeceptjs parser: Parse CodeceptJS hooks code - default opts: should include BeforeSuite hook code
+ codeceptjs parser: Parse CodeceptJS hooks code - default opts: should include AfterSuite hook code
+ codeceptjs parser: [opts.noHooks = true] Parse CodeceptJS hooks code: should exclude Before hook code
+ codeceptjs parser: [opts.noHooks = true] Parse CodeceptJS hooks code: should exclude BeforeSuite hook code
+ codeceptjs parser: [opts.noHooks = true] Parse CodeceptJS hooks code: should exclude AfterSuite hook code
+ codeceptjs parser: Parse CodeceptJS test with --line-numbers option: [lineNumbers=true opts] each section should include line-number as part of code section
+ codeceptjs parser: Parse CodeceptJS test with --line-numbers option: [no SET the lineNumbers opts] should exclude line-number
+ codeceptjs parser: Parse CodeceptJS test with --line-numbers option: [noHooks=true + lineNumbers=true opts] line-number as part of code section
+ Comment: should refer to proper skipped line in comment
+ Decorator: should print markdown
+ Decorator: should validate tests with empty titles
+ Decorator: should print markdown2
+ jasmine parser: jasmine tests: should parse jasmine file
+ jasmine parser: jasmine tests: should include code
+ jest parser: jest tests: should parse jest file
+ jest parser: jest tests: should include code
+ jest parser: exclusive tests: should throw an error if a file contains .only
+ jest parser: hooks tests - default opts: should include beforeAll hook code
+ jest parser: hooks tests - default opts: should include beforeEach hook code
+ jest parser: hooks tests - default opts: should include afterAll hook code
+ jest parser: [opts.noHooks = true] hooks tests: should exclude beforeAll hook code
+ jest parser: [opts.noHooks = true] hooks tests: should exclude beforeEach hook code
+ jest parser: [opts.noHooks = true] hooks tests: should exclude after hook code
+ jest parser: test with --line-numbers option: [lineNumbers=true opts] each section should include line-number as part of code section
+ jest parser: test with --line-numbers option: [no SET the lineNumbers opts] should exclude line-number
+ jest parser: test with --line-numbers option: [noHooks=true + lineNumbers=true opts] line-number as part of code section
+ mocha parser: mocha tests: should parse mocha file
+ mocha parser: cypress tests: should parse cypress file
+ mocha parser: cypress tests: should include code
+ mocha parser: graphql tests: should parse codeceptjs internal test
+ mocha parser: Cypress: hooks tests: should include before hook code by default
+ mocha parser: Cypress: hooks tests: should include beforeEach hook code by default
+ mocha parser: Cypress: hooks tests: should include after hook code by default
+ mocha parser: [opts.noHooks = true] Cypress: hooks code: should exclude before hook code
+ mocha parser: [opts.noHooks = true] Cypress: hooks code: should exclude beforeEach hook code
+ mocha parser: [opts.noHooks = true] Cypress: hooks code: should exclude after hook code
+ mocha parser: Cypress: test with --line-numbers option: [lineNumbers=true opts] each section should include line-number as part of code section
+ mocha parser: Cypress: test with --line-numbers option: [no SET the lineNumbers opts] should exclude line-number
+ mocha parser: Cypress: test with --line-numbers option: [noHooks=true + lineNumbers=true opts] line-number as part of code section
+ newman parser: should parse newman collection
+ newman parser: should properly get test name
+ newman parser: should properly get suites for test inside nested folder
+ newman parser: should properly get suite for test within collection (not in any folder)
+ playwright parser: should parse basic playwright-js tests
+ playwright parser: should forbid describe.only tests
+ playwright parser: should parse basic playwright-ts tests
+ playwright parser: should parse multiple playwright-js tests
+ playwright parser: should parse multiple playwright-ts tests
+ playwright parser: should update playwright suite if no suite set
+ playwright parser: tags: should parse playwright-ts test with signle tag on the same line
+ playwright parser: tags: should parse playwright-ts test with opening brace on the same line and signle tag on the next line
+ playwright parser: tags: should parse playwright-ts test with signle tag on the next line
+ playwright parser: tags: should parse playwright-js test with multiple tags
+ playwright parser: tags: should parse playwright-js test with multiple tags on multiple lines
+ playwright parser: tags: should parse playwright-ts tests with params
+ playwright parser: tags: should parse playwright-js tests with annotation
+ playwright parser: tags: should parse playwright-js tests with annotation including fixme
+ playwright parser: tags: should parse playwright-ts tests with annotations
+ playwright parser: tags: should parse playwright test with test.skip annotation inside a test
+ playwright parser: tags: should parse playwright-js tests with skip() annotation for the description and test sections
+ playwright parser: tags: should parse playwright-js tests with fixme() annotation for the description and test sections
+ playwright parser: Parse Playwright hooks code - default opts: should include beforeAll hook code
+ playwright parser: Parse Playwright hooks code - default opts: should include beforeEach hook code
+ playwright parser: Parse Playwright hooks code - default opts: should include afterAll hook code
+ playwright parser: [opts.noHooks = true] Parse Playwright hooks code: should exclude beforeAll hook code
+ playwright parser: [opts.noHooks = true] Parse Playwright hooks code: should exclude beforeEach hook code
+ playwright parser: [opts.noHooks = true] Parse Playwright hooks code: should exclude afterAll hook code
+ playwright parser: Default playwright file parsing : should parse basic playwright-ts DEMO tests ("todo" name as part of inner function args)
+ playwright parser: Default playwright file parsing : should return suite name if used test.describe without parallel mode
+ playwright parser: Default playwright file parsing : should return suite name if used test.describe.parallel mode
+ playwright parser: Default playwright file parsing : should return suite name if used test.describe.serial mode
+ playwright parser: test with --line-numbers option: [lineNumbers=true opts] each section should include line-number as part of code section
+ playwright parser: test with --line-numbers option: [no SET the lineNumbers opts] should exclude line-number
+ playwright parser: test with --line-numbers option: [noHooks=true + lineNumbers=true opts] line-number as part of code section
+ qunit parser: qunit tests: should parse qunit file
+ testcafe parser: Testcafe tests: should parse testcafe file
+ testcafe parser: Testcafe tests: should include testcafe code
+ UpdateIds FS: should add suite and test ids
+ UpdateIds FS: should clean suite and test ids safely
+ UpdateIds FS: should clean suite and test ids unsafely
+ update ids tests(codeseptJS adapter): [codeseptJS examples] includes Feature + Scenario: [js file]: file includes Feature + one Scenario
+ update ids tests(codeseptJS adapter): [codeseptJS examples] includes Feature + Scenario: [js file]: test file does not include Feature, only Scenario
+ update ids tests(codeseptJS adapter): [codeseptJS examples] includes Feature + Scenario: [js file]: test file does not include Scenario, only Feature
+ update ids tests(codeseptJS adapter): [codeseptJS examples] clean-ids: can remove ids from the file with Scenario only
+ update ids tests(codeseptJS adapter): [codeseptJS examples] clean-ids: can remove ids form the Feature & Scenario
+ update ids tests(playwright adapter): [Playwright examples] includes/no includes main suite: [ts file]: test file includes suite with tests
+ update ids tests(playwright adapter): [Playwright examples] includes/no includes main suite: [ts file]: test file does not include suite name, only tests
+ update ids tests(playwright adapter): [Playwright examples] includes/no includes main suite: [ts file]: test file test.describe.parallel mode should returns updated title.
+ update ids tests(playwright adapter): [Playwright examples] lines processing: [ts file]: the same import name as suite name
+ update ids tests(playwright adapter): [Playwright examples] lines processing: [ts file]: test file without imports should update only suite & test name
+ update ids tests(playwright adapter): [Playwright examples] lines processing: [js file]: the same require name as suite name
+ update ids tests(playwright adapter): [Playwright examples] lines processing: [js file]: suite name as a new line
+ update ids tests(playwright adapter): [Playwright examples] lines processing: test.skip() annotation inside a test is propersly processed
+ update ids tests(playwright adapter): [Playwright examples] clean-ids for the --typescript mode: can remove ids from the file with suite
+ update ids tests(playwright adapter): [Playwright examples] clean-ids for the --typescript mode: can remove ids if no suites in the file
+ update ids: update-ids: should update id by title
+ update ids: update-ids: should update id with tags by title
+ update ids: update-ids: updates ids from server
+ update ids: update-ids: ignore duplicates for ids from server
+ update ids: update-ids: should not update other strings in file
+ update ids: update-ids: allows multi-line titles
+ update ids: update-ids: respects string literals
+ update ids: update-ids: respects variables in string literals
+ update ids: update-ids: respects variables in string literals and JSON report mode
+ update ids: update-ids: respects variables in string literals in double param and JSON report mode
+ update ids: update-ids: works ok with empty files
+ update ids: update-ids: supports typescript
+ update ids: update-ids: supports typescript with types
+ update ids: update-ids: should not reformat the Array code with --typescript option
+ update ids: clean-ids: cleans up ids from strings
+ update ids: clean-ids: cleans up ids from string literals
+ update ids: clean-ids: unsafely cleans up ids from string literals
+ update ids: clean-ids: can remove ids from typescript
+ util functions: #replaceAtPoint
📑 List all tests

📝 tests/analyzer_test.js

  • 📎 analyzer
    • ✔️ can import analyzer from main index
    • ✔️ should parse all mocha files
    • ✔️ should parse all typescript files
    • ✔️ should exclude dir in file name if dir specified
    • ✔️ should include full dir in file name
    • ✔️ should avoid node_modules
    • ✔️ should read char`
    • ✔️ should not load dirs as files
    • 📎 env variable params
      • ✔️ should prepend a dir from env variable

📝 tests/codeceptjs_test.js

  • 📎 codeceptjs parser
    • 📎 create todo tests
      • ✔️ should parse codecept file
      • ✔️ should include code
    • 📎 Parse CodeceptJS tags
      • ✔️ should include tags
    • 📎 Parse CodeceptJS tags & datatable
      • ✔️ should include data and tags
    • 📎 Parse CodeceptJS hooks code - default opts
      • ✔️ should include Before hook code
      • ✔️ should include BeforeSuite hook code
      • ✔️ should include AfterSuite hook code
    • 📎 [opts.noHooks = true] Parse CodeceptJS hooks code
      • ✔️ should exclude Before hook code
      • ✔️ should exclude BeforeSuite hook code
      • ✔️ should exclude AfterSuite hook code
    • 📎 Parse CodeceptJS test with --line-numbers option
      • ✔️ [lineNumbers=true opts] each section should include line-number as part of code section
      • ✔️ [no SET the lineNumbers opts] should exclude line-number
      • ✔️ [noHooks=true + lineNumbers=true opts] line-number as part of code section

📝 tests/comment_test.js

  • 📎 Comment
    • ✔️ should refer to proper skipped line in comment

📝 tests/decorator_test.js

  • 📎 Decorator
    • ✔️ should print markdown
    • ✔️ should validate tests with empty titles
    • ✔️ should print markdown2

📝 tests/jasmine_test.js

  • 📎 jasmine parser
    • 📎 jasmine tests
      • ✔️ should parse jasmine file
      • ✔️ should include code

📝 tests/jest_test.js

  • 📎 jest parser
    • 📎 jest tests
      • ✔️ should parse jest file
      • ✔️ should include code
    • 📎 exclusive tests
      • ✔️ should throw an error if a file contains .only
    • 📎 hooks tests - default opts
      • ✔️ should include beforeAll hook code
      • ✔️ should include beforeEach hook code
      • ✔️ should include afterAll hook code
    • 📎 [opts.noHooks = true] hooks tests
      • ✔️ should exclude beforeAll hook code
      • ✔️ should exclude beforeEach hook code
      • ✔️ should exclude after hook code
    • 📎 test with --line-numbers option
      • ✔️ [lineNumbers=true opts] each section should include line-number as part of code section
      • ✔️ [no SET the lineNumbers opts] should exclude line-number
      • ✔️ [noHooks=true + lineNumbers=true opts] line-number as part of code section

📝 tests/mocha_test.js

  • 📎 mocha parser
    • 📎 mocha tests
      • ✔️ should parse mocha file
    • 📎 cypress tests
      • ✔️ should parse cypress file
      • ✔️ should include code
    • 📎 graphql tests
      • ✔️ should parse codeceptjs internal test
    • 📎 Cypress: hooks tests
      • ✔️ should include before hook code by default
      • ✔️ should include beforeEach hook code by default
      • ✔️ should include after hook code by default
    • 📎 [opts.noHooks = true] Cypress: hooks code
      • ✔️ should exclude before hook code
      • ✔️ should exclude beforeEach hook code
      • ✔️ should exclude after hook code
    • 📎 Cypress: test with --line-numbers option
      • ✔️ [lineNumbers=true opts] each section should include line-number as part of code section
      • ✔️ [no SET the lineNumbers opts] should exclude line-number
      • ✔️ [noHooks=true + lineNumbers=true opts] line-number as part of code section

📝 tests/newman_test.js

  • 📎 newman parser
    • ✔️ should parse newman collection
    • ✔️ should properly get test name
    • ✔️ should properly get suites for test inside nested folder
    • ✔️ should properly get suite for test within collection (not in any folder)

📝 tests/playwright_test.js

  • 📎 playwright parser
    • ✔️ should parse basic playwright-js tests
    • ✔️ should forbid describe.only tests
    • ✔️ should parse basic playwright-ts tests
    • ✔️ should parse multiple playwright-js tests
    • ✔️ should parse multiple playwright-ts tests
    • ✔️ should update playwright suite if no suite set
    • 📎 tags
      • ✔️ should parse playwright-ts test with signle tag on the same line
      • ✔️ should parse playwright-ts test with opening brace on the same line and signle tag on the next line
      • ✔️ should parse playwright-ts test with signle tag on the next line
      • ✔️ should parse playwright-js test with multiple tags
      • ✔️ should parse playwright-js test with multiple tags on multiple lines
      • ✔️ should parse playwright-ts tests with params
      • ✔️ should parse playwright-js tests with annotation
      • ✔️ should parse playwright-js tests with annotation including fixme
      • ✔️ should parse playwright-ts tests with annotations
      • ✔️ should parse playwright test with test.skip annotation inside a test
      • ✔️ should parse playwright-js tests with skip() annotation for the description and test sections
      • ✔️ should parse playwright-js tests with fixme() annotation for the description and test sections
    • 📎 Parse Playwright hooks code - default opts
      • ✔️ should include beforeAll hook code
      • ✔️ should include beforeEach hook code
      • ✔️ should include afterAll hook code
    • 📎 [opts.noHooks = true] Parse Playwright hooks code
      • ✔️ should exclude beforeAll hook code
      • ✔️ should exclude beforeEach hook code
      • ✔️ should exclude afterAll hook code
    • 📎 **Default playwright file parsing **
      • ✔️ should parse basic playwright-ts DEMO tests ("todo" name as part of inner function args)
      • ✔️ should return suite name if used test.describe without parallel mode
      • ✔️ should return suite name if used test.describe.parallel mode
      • ✔️ should return suite name if used test.describe.serial mode
    • 📎 test with --line-numbers option
      • ✔️ [lineNumbers=true opts] each section should include line-number as part of code section
      • ✔️ [no SET the lineNumbers opts] should exclude line-number
      • ✔️ [noHooks=true + lineNumbers=true opts] line-number as part of code section

📝 tests/qunit_test.js

  • 📎 qunit parser
    • 📎 qunit tests
      • ✔️ should parse qunit file

📝 tests/testcafe_test.js

  • 📎 testcafe parser
    • 📎 Testcafe tests
      • ✔️ should parse testcafe file
      • ✔️ should include testcafe code

📝 tests/update_fs_test.js

  • 📎 UpdateIds FS
    • ✔️ should add suite and test ids
    • ✔️ should clean suite and test ids safely
    • ✔️ should clean suite and test ids unsafely

📝 tests/updateIds_codeceptjs_test.js

  • 📎 update ids tests(codeseptJS adapter)
    • 📎 [codeseptJS examples] includes Feature + Scenario
      • ✔️ [js file]: file includes Feature + one Scenario
      • ✔️ [js file]: test file does not include Feature, only Scenario
      • ✔️ [js file]: test file does not include Scenario, only Feature
    • 📎 [codeseptJS examples] clean-ids
      • ✔️ can remove ids from the file with Scenario only
      • ✔️ can remove ids form the Feature & Scenario

📝 tests/updateIds_playwright_test.js

  • 📎 update ids tests(playwright adapter)
    • 📎 [Playwright examples] includes/no includes main suite
      • ✔️ [ts file]: test file includes suite with tests
      • ✔️ [ts file]: test file does not include suite name, only tests
      • ✔️ [ts file]: test file test.describe.parallel mode should returns updated title.
    • 📎 [Playwright examples] lines processing
      • ✔️ [ts file]: the same import name as suite name
      • ✔️ [ts file]: test file without imports should update only suite & test name
      • ✔️ [js file]: the same require name as suite name
      • ✔️ [js file]: suite name as a new line
      • ✔️ test.skip() annotation inside a test is propersly processed
    • 📎 [Playwright examples] clean-ids for the --typescript mode
      • ✔️ can remove ids from the file with suite
      • ✔️ can remove ids if no suites in the file

📝 tests/updateIds_test.js

  • 📎 update ids
    • 📎 update-ids
      • ✔️ should update id by title
      • ✔️ should update id with tags by title
      • ✔️ updates ids from server
      • ✔️ ignore duplicates for ids from server
      • ✔️ should not update other strings in file
      • ✔️ allows multi-line titles
      • ✔️ respects string literals
      • ✔️ respects variables in string literals
      • ✔️ respects variables in string literals and JSON report mode
      • ✔️ respects variables in string literals in double param and JSON report mode
      • ✔️ works ok with empty files
      • ✔️ supports typescript
      • ✔️ supports typescript with types
      • ✔️ should not reformat the Array code with --typescript option
    • 📎 clean-ids
      • ✔️ cleans up ids from strings
      • ✔️ cleans up ids from string literals
      • ✔️ unsafely cleans up ids from string literals
      • ✔️ can remove ids from typescript

📝 tests/utils_test.js

  • 📎 util functions
    • ✔️ #replaceAtPoint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant