diff --git a/specs/Modal.spec.js b/specs/Modal.spec.js index d008dbf0..cf3d3d44 100644 --- a/specs/Modal.spec.js +++ b/specs/Modal.spec.js @@ -417,6 +417,14 @@ export default () => { unmountModal(); }); + it("additional testId attribute", () => { + const modal = renderModal({ isOpen: true, testId: "foo-bar" }, "hello"); + mcontent(modal) + .getAttribute("data-testid") + .should.be.eql("foo-bar"); + unmountModal(); + }); + it("raises an exception if the appElement selector does not match", () => { should(() => ariaAppHider.setElement(".test")).throw(); }); diff --git a/src/components/ModalPortal.js b/src/components/ModalPortal.js index e50d9911..4d852193 100644 --- a/src/components/ModalPortal.js +++ b/src/components/ModalPortal.js @@ -348,6 +348,7 @@ export default class ModalPortal extends Component { aria-label={this.props.contentLabel} {...this.attributesFromObject("aria", this.props.aria || {})} {...this.attributesFromObject("data", this.props.data || {})} + data-testid={this.props.testId} > {this.props.children}