While working on my Protractor test, I encountered a syntax error on import when trying to bring an external class into the test. The strange thing is that the error only occurs at runtime, even though I am confident that I am importing and exporting the class correctly. Initially, the test worked fine when the class was part of the same project. However, now that I am referencing it from an external project, the issue arises.
SyntaxError: Unexpected token {
import { Helper } from './src/helper';
^
Main Project
test.ts
import { Helper, People, Groups } from 'sub-project';
describe('Test Description', () => {
let helper: Helper;
let people: People;
let groups: Groups;
before(async () => {
helper = new Helper();
people = new People();
groups = new Groups();
});
Sub-Project
export class Helper {
private httpClient = new HttpClient();
public async myFunction(): {
}
}
app.ts
import { Helper } from './src/helper';
import { People } from './src/people';
import { Groups } from './src/groups';
export { Helper, People, Groups };
tsconfig.json
{
"compilerOptions": {
"outDir": "lib",
"rootDir": ".",
"target": "es5",
"module": "commonjs",
"types": [
"chai",
"chai-as-promised",
"mocha"
]
}
}