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

Legacy runtime API for Allure Mocha #975

Closed
wants to merge 10 commits into from
Closed

Conversation

delatrie
Copy link
Collaborator

@delatrie delatrie commented May 24, 2024

Context

The legacy API makes Allure Mocha compatible with the code written against pre-3.0 allure-mocha/runtime. The references are Allure.ts and MochaAllure.ts.

Issues:

  • No logStep in the new Runtime API (not a big deal, since the legacy logStep can be implemented in terms of step; logStep in 2.15.1 doesn't support custom statuses anyway, so we don't break it).
  • The legacy attachment's 3rd argument can be an instance of AttachmentOptions. The new API doesn't allow that. While AttachmentOptions.contentType could be provided directly, there is no way to pass AttachmentOptions.fileExtension.

TODO:

  • test testAttachment
  • test step's return value

Extra changes

Reporter's new name

The reporter class's name now is AllureMochaReporter (following a general convention Allure<Framework><ExtensionMechanism>.

CommonJS export change for AllureMochaReporter

The CommonJS build of Allure Mocha now exports the reporter class directly as module.exports. That allows users to specify the reporter via CLI: npx mocha --reporter allure-mocha .... That also makes the new version more look-alike with the previous one.

More comprehensive testing of Allure Mocha

The test runner now allows to test running Mocha from code (both CommonJS and ESM). The behavior can be controlled with ALLURE_MOCHA_TEST_RUNNER env var, which supports the following values: cli, cjs, and esm.

ALLURE_MOCHA_TEST_SPEC_FORMAT allows choosing between CommonJS (cjs) and ESM (esm) testing samples.

ALLURE_MOCHA_TEST_PARALLEL allows testing the parallel mode of Mocha.

Currently, only the following two combinations are tested in the CI:

  • Runner: cli, specs: esm, parallel: no
  • Runner: cli, specs: esm, parallel: yes

ESLint config changes

All files inside dist folders are now ignored by ESLint.

Checklist

@delatrie delatrie added the type:improvement Improvement or request label May 24, 2024
@github-actions github-actions bot added the theme:mocha Mocha related issue label May 24, 2024
@delatrie delatrie force-pushed the mocha-backward-compat branch 2 times, most recently from c03a83c to 830fee4 Compare May 27, 2024 09:12
@delatrie delatrie force-pushed the mocha-backward-compat branch from 830fee4 to b75f966 Compare May 27, 2024 12:51
@github-actions github-actions bot added the theme:api Javascript API related issue label May 27, 2024
@delatrie delatrie marked this pull request as ready for review May 27, 2024 13:41
epszaw added a commit that referenced this pull request May 31, 2024
@epszaw epszaw mentioned this pull request May 31, 2024
2 tasks
baev pushed a commit that referenced this pull request Jun 3, 2024
@delatrie delatrie marked this pull request as draft June 3, 2024 14:02
@delatrie delatrie closed this Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme:api Javascript API related issue theme:mocha Mocha related issue type:improvement Improvement or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant