Skip to content

fix: ES2015 for karma tests #88

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

Merged
merged 1 commit into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 76 additions & 2 deletions projects/testing-library/src/lib/testing-library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,6 @@ function detectChangesForMountedFixtures() {
mountedFixtures.forEach(fixture => fixture.detectChanges());
}

export * from '@testing-library/dom';

const fireEvent = Object.keys(dtlFireEvent).reduce(
(events, key) => {
events[key] = (element: HTMLElement, options?: {}) => {
Expand All @@ -308,4 +306,80 @@ const fireEvent = Object.keys(dtlFireEvent).reduce(

const screen = replaceFindWithFindAndDetectChanges(document.body, dtlScreen);

// manually export otherwise we get the following error while running Jest tests
// TypeError: Cannot set property fireEvent of [object Object] which has only a getter
// exports.fireEvent = fireEvent;
export {
buildQueries,
configure,
getByLabelText,
getAllByLabelText,
queryByLabelText,
queryAllByLabelText,
findByLabelText,
findAllByLabelText,
getByPlaceholderText,
getAllByPlaceholderText,
queryByPlaceholderText,
queryAllByPlaceholderText,
findByPlaceholderText,
findAllByPlaceholderText,
getByText,
getAllByText,
queryByText,
queryAllByText,
findByText,
findAllByText,
getByAltText,
getAllByAltText,
queryByAltText,
queryAllByAltText,
findByAltText,
findAllByAltText,
getByTitle,
getAllByTitle,
queryByTitle,
queryAllByTitle,
findByTitle,
findAllByTitle,
getByDisplayValue,
getAllByDisplayValue,
queryByDisplayValue,
queryAllByDisplayValue,
findByDisplayValue,
findAllByDisplayValue,
getByRole,
getAllByRole,
queryByRole,
queryAllByRole,
findByRole,
findAllByRole,
getByTestId,
getAllByTestId,
queryByTestId,
queryAllByTestId,
findByTestId,
findAllByTestId,
createEvent,
getDefaultNormalizer,
getElementError,
getNodeText,
getQueriesForElement,
getRoles,
isInaccessible,
logDOM,
logRoles,
prettyDOM,
queries,
queryAllByAttribute,
queryByAttribute,
queryHelpers,
wait,
waitFor,
waitForDomChange,
waitForElement,
waitForElementToBeRemoved,
within,
} from '@testing-library/dom';

export { fireEvent, screen };
6 changes: 1 addition & 5 deletions projects/testing-library/src/lib/user-events/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { fireEvent } from '@testing-library/dom';
import { createType } from './type';
import { createSelectOptions } from './selectOptions';
import { tab } from './tab';
Expand Down Expand Up @@ -47,7 +46,4 @@ export interface UserEvents {
tab: typeof tab;
}

const type = createType(fireEvent);
const selectOptions = createSelectOptions(fireEvent);

export { createType, type, createSelectOptions, selectOptions, tab };
export { createType, createSelectOptions, tab };
2 changes: 1 addition & 1 deletion projects/testing-library/src/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
*/

export * from './lib/models';
export * from './lib/testing-library';
export * from './lib/user-events';
export * from './lib/testing-library';
2 changes: 1 addition & 1 deletion projects/testing-library/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"outDir": "../../out-tsc/lib",
"target": "es2015",
"module": "CommonJS",
"module": "ES2015",
"moduleResolution": "node",
"declaration": true,
"sourceMap": true,
Expand Down