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

feat: allow configuring options for setup test env #1657

Merged
merged 1 commit into from
Jun 25, 2022

Conversation

cedricduffournet
Copy link
Contributor

Summary

Users can configure all TestEnvironmentOptions via globalThis in the setup Jest file.

globalThis.ngJest = {
  testEnvironmentOptions: {
    teardown: {
      destroyAfterEach: false,
      rethrowErrors: true,
    },
    errorOnUnknownElements: true,
    errorOnUnknownProperties: true,
  },
};

closes #1656

Test plan

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

N.A.

Copy link
Collaborator

@ahnpnl ahnpnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only 2 small changes, the rest LGTM

setup-jest.js Outdated
@@ -5,23 +5,36 @@ const {
platformBrowserDynamicTesting,
} = require('@angular/platform-browser-dynamic/testing');

let teardown = globalThis.ngJest?.teardown;
let testEnvironmentOptions = globalThis.ngJest?.testEnvironmentOptions;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let testEnvironmentOptions = globalThis.ngJest?.testEnvironmentOptions;
let testEnvironmentOptions = globalThis.ngJest?.testEnvironmentOptions ?? Object.create(null);

setup-jest.mjs Outdated
@@ -2,22 +2,36 @@ import 'zone.js/fesm2015/zone-testing-bundle.min.js';
import { getTestBed } from '@angular/core/testing';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';

let teardown = globalThis.ngJest?.teardown;
const configuredDestroyAfterEach = globalThis.ngJest?.destroyAfterEach;
let testEnvironmentOptions = globalThis.ngJest?.testEnvironmentOptions;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as the one in setup-jest.js

@cedricduffournet cedricduffournet force-pushed the feat/config-test-env-options branch from a20e695 to 35fc752 Compare June 25, 2022 13:46
@cedricduffournet cedricduffournet requested a review from ahnpnl June 25, 2022 13:46
Copy link
Collaborator

@ahnpnl ahnpnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ahnpnl ahnpnl merged commit a64a4ac into thymikee:main Jun 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: Allow configuring errorOnUnknownElements and errorOnUnknownProperties for setup test env
2 participants