Skip to content

Commit 0438b77

Browse files
fix: compile as ES2015 to supprt karma tests
Closes #87
2 parents 4520fb8 + 8e17700 commit 0438b77

File tree

4 files changed

+79
-9
lines changed

4 files changed

+79
-9
lines changed

projects/testing-library/src/lib/testing-library.ts

+76-2
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,6 @@ function detectChangesForMountedFixtures() {
292292
mountedFixtures.forEach(fixture => fixture.detectChanges());
293293
}
294294

295-
export * from '@testing-library/dom';
296-
297295
const fireEvent = Object.keys(dtlFireEvent).reduce(
298296
(events, key) => {
299297
events[key] = (element: HTMLElement, options?: {}) => {
@@ -308,4 +306,80 @@ const fireEvent = Object.keys(dtlFireEvent).reduce(
308306

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

309+
// manually export otherwise we get the following error while running Jest tests
310+
// TypeError: Cannot set property fireEvent of [object Object] which has only a getter
311+
// exports.fireEvent = fireEvent;
312+
export {
313+
buildQueries,
314+
configure,
315+
getByLabelText,
316+
getAllByLabelText,
317+
queryByLabelText,
318+
queryAllByLabelText,
319+
findByLabelText,
320+
findAllByLabelText,
321+
getByPlaceholderText,
322+
getAllByPlaceholderText,
323+
queryByPlaceholderText,
324+
queryAllByPlaceholderText,
325+
findByPlaceholderText,
326+
findAllByPlaceholderText,
327+
getByText,
328+
getAllByText,
329+
queryByText,
330+
queryAllByText,
331+
findByText,
332+
findAllByText,
333+
getByAltText,
334+
getAllByAltText,
335+
queryByAltText,
336+
queryAllByAltText,
337+
findByAltText,
338+
findAllByAltText,
339+
getByTitle,
340+
getAllByTitle,
341+
queryByTitle,
342+
queryAllByTitle,
343+
findByTitle,
344+
findAllByTitle,
345+
getByDisplayValue,
346+
getAllByDisplayValue,
347+
queryByDisplayValue,
348+
queryAllByDisplayValue,
349+
findByDisplayValue,
350+
findAllByDisplayValue,
351+
getByRole,
352+
getAllByRole,
353+
queryByRole,
354+
queryAllByRole,
355+
findByRole,
356+
findAllByRole,
357+
getByTestId,
358+
getAllByTestId,
359+
queryByTestId,
360+
queryAllByTestId,
361+
findByTestId,
362+
findAllByTestId,
363+
createEvent,
364+
getDefaultNormalizer,
365+
getElementError,
366+
getNodeText,
367+
getQueriesForElement,
368+
getRoles,
369+
isInaccessible,
370+
logDOM,
371+
logRoles,
372+
prettyDOM,
373+
queries,
374+
queryAllByAttribute,
375+
queryByAttribute,
376+
queryHelpers,
377+
wait,
378+
waitFor,
379+
waitForDomChange,
380+
waitForElement,
381+
waitForElementToBeRemoved,
382+
within,
383+
} from '@testing-library/dom';
384+
311385
export { fireEvent, screen };

projects/testing-library/src/lib/user-events/index.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { fireEvent } from '@testing-library/dom';
21
import { createType } from './type';
32
import { createSelectOptions } from './selectOptions';
43
import { tab } from './tab';
@@ -47,7 +46,4 @@ export interface UserEvents {
4746
tab: typeof tab;
4847
}
4948

50-
const type = createType(fireEvent);
51-
const selectOptions = createSelectOptions(fireEvent);
52-
53-
export { createType, type, createSelectOptions, selectOptions, tab };
49+
export { createType, createSelectOptions, tab };

projects/testing-library/src/public_api.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
*/
44

55
export * from './lib/models';
6-
export * from './lib/testing-library';
76
export * from './lib/user-events';
7+
export * from './lib/testing-library';

projects/testing-library/tsconfig.lib.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"compilerOptions": {
44
"outDir": "../../out-tsc/lib",
55
"target": "es2015",
6-
"module": "CommonJS",
6+
"module": "ES2015",
77
"moduleResolution": "node",
88
"declaration": true,
99
"sourceMap": true,

0 commit comments

Comments
 (0)