I have a project written in Typescript which uses jasmine-ts to run a series of tests.
I need to create a Docker container to run the tests for a few reasons.
Whilst the project locally runs OK npm test:
c:\github\gareththegeek\corewar>npm test
> [email protected] test c:\github\gareththegeek\corewar
> nyc jasmine-ts
Started
.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
503 specs, 0 failures
Finished in 0.893 seconds
When I containerise the same folder and run npm test from the docker image, the Typescript imports don't seem to be recognised.
c:\github\gareththegeek\corewar>docker run corewar
> [email protected] test /usr/src/app
> nyc jasmine-ts
/usr/src/app/node_modules/ts-node/src/index.ts:307
throw new TSError(formatDiagnostics(diagnosticList, cwd, ts, lineOffset))
^
TSError: ⨯ Unable to compile TypeScript
parser/Expression.ts (1,29): Cannot find module './interface/IExpression'. (2307)
parser/Expression.ts (2,39): Cannot find module './interface/IToken'. (2307)
parser/Expression.ts (3,30): Cannot find module './interface/ITokenStream'. (230
My docker image is as basic as it comes:
FROM node:carbon
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
COPY package*.json ./
RUN npm install
# Bundle app source
COPY . .
CMD [ "npm", "test" ]
I'm really unsure why the docker container behaves differently to my local npm test command. I'm going to assume it's because locally I'm on windows and the docker container isn't. But I'm really unsure how to debug this.
Can anyone give any pointers on why Typescript imports aren't working within docker the way I'm expecting them too? I can paste over some of the Typescript code if it's any help.