diff --git a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsView.test.tsx b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsView.test.tsx
index 3f416dcceb..a26d6e3803 100644
--- a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsView.test.tsx
+++ b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsView.test.tsx
@@ -31,19 +31,6 @@ jest.mock('react-virtualized-auto-sizer', () => ({
}) => <>{props.children({ width: 400, height: 200 })}>,
}));
-// Patch jsdom to add feature used by CodeMirror
-document.createRange = () => {
- const range = new Range();
-
- range.getClientRects = () => ({
- item: () => null,
- length: 0,
- [Symbol.iterator]: jest.fn(),
- });
-
- return range;
-};
-
function DryRunRemote() {
const dryRun = useDryRun();
diff --git a/plugins/scaffolder/src/components/TemplateEditorPage/TemplateEditorPage.test.tsx b/plugins/scaffolder/src/components/TemplateEditorPage/TemplateEditorPage.test.tsx
new file mode 100644
index 0000000000..bf9cd8c464
--- /dev/null
+++ b/plugins/scaffolder/src/components/TemplateEditorPage/TemplateEditorPage.test.tsx
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2022 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { catalogApiRef } from '@backstage/plugin-catalog-react';
+import { renderInTestApp, TestApiProvider } from '@backstage/test-utils';
+import { screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import React from 'react';
+import { TemplateEditorPage } from './TemplateEditorPage';
+
+describe('TemplateEditorPage', () => {
+ it('renders without exploding', async () => {
+ await renderInTestApp();
+
+ expect(screen.getByText('Load Template Directory')).toBeInTheDocument();
+ expect(screen.getByText('Edit Template Form')).toBeInTheDocument();
+ });
+
+ it('template directory loading should not be supported in Jest', async () => {
+ await renderInTestApp();
+
+ expect(
+ screen.getByRole('button', { name: /Load Template Directory/ }),
+ ).toBeDisabled();
+ });
+
+ it('should be able to continue to form preview', async () => {
+ await renderInTestApp(
+
+
+ ,
+ );
+
+ await userEvent.click(screen.getByText('Edit Template Form'));
+
+ expect(screen.getByLabelText('Load Existing Template')).toBeInTheDocument();
+ });
+});
diff --git a/plugins/scaffolder/src/setupTests.ts b/plugins/scaffolder/src/setupTests.ts
index 10252413a7..5499f969dc 100644
--- a/plugins/scaffolder/src/setupTests.ts
+++ b/plugins/scaffolder/src/setupTests.ts
@@ -19,3 +19,16 @@ import 'cross-fetch/polyfill';
const { EventSourcePolyfill } = jest.requireMock('event-source-polyfill');
global.EventSource = EventSourcePolyfill;
+
+// Patch jsdom to add feature used by CodeMirror
+document.createRange = () => {
+ const range = new Range();
+
+ range.getClientRects = () => ({
+ item: () => null,
+ length: 0,
+ [Symbol.iterator]: jest.fn(),
+ });
+
+ return range;
+};