My angular app does not work on stackblitz when I added a test case.
I'm getting this weird error: Import error, can't find file: ./test-files.ts
.
It worked fine before adding the test.
Asked
Active
Viewed 167 times
0

fastcodejava
- 39,895
- 28
- 133
- 186
2 Answers
1
first you should install:
jasmine-core
@types/jasmine
then add a jasmine-setup to your project:
import jasmineRequire from 'jasmine-core/lib/jasmine-core/jasmine.js';
window.jasmineRequire = jasmineRequire;
and in typings.d
:
interface Window {
jasmineRequire: any;
jasmineRef: any;
}
declare module 'jasmine-core/lib/jasmine-core/jasmine.js' {}
and in your main.ts:
let TEST = true;
if (TEST) {
(function bootstrap () {
if (window.jasmineRef) {
location.reload();
return;
}
window.onload(new Event('anything'));
window.jasmineRef = jasmine.getEnv();
}());
}
this Stackblitz example can help you.

Fateme Fazli
- 11,582
- 2
- 31
- 48
0
You added your test-files in outside of the src. Add it inside the src.
Or Change the main.ts import as '../test-files.ts'

Amith Dissanayaka
- 939
- 3
- 12
- 23