From 2bca273ff4230381319c2e5713ef5b934dfa8c1e Mon Sep 17 00:00:00 2001 From: Michael Irwin Date: Tue, 22 Nov 2022 23:27:02 -0500 Subject: [PATCH] Fix Dockerfile build to actually run tests and fix a unit test Signed-off-by: Michael Irwin --- Dockerfile | 5 ++--- app/spec/routes/addItem.spec.js | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4b43f6d..2bc1f44 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ WORKDIR /app COPY requirements.txt . RUN pip install -r requirements.txt -FROM node:12-alpine AS app-base +FROM node:18-alpine AS app-base WORKDIR /app COPY app/package.json app/yarn.lock ./ COPY app/spec ./spec @@ -13,13 +13,12 @@ COPY app/src ./src # Run tests to validate app FROM app-base AS test -RUN apk add --no-cache python3 g++ make RUN yarn install RUN yarn test # Clear out the node_modules and create the zip FROM app-base AS app-zip-creator -COPY app/package.json app/yarn.lock ./ +COPY --from=test /app/package.json /app/yarn.lock ./ COPY app/spec ./spec COPY app/src ./src RUN apk add zip && \ diff --git a/app/spec/routes/addItem.spec.js b/app/spec/routes/addItem.spec.js index 0ec5e11..f60c06b 100644 --- a/app/spec/routes/addItem.spec.js +++ b/app/spec/routes/addItem.spec.js @@ -1,9 +1,9 @@ const db = require('../../src/persistence'); const addItem = require('../../src/routes/addItem'); const ITEM = { id: 12345 }; -const uuid = require('uuid/v4'); +const {v4 : uuid} = require('uuid'); -jest.mock('uuid/v4', () => jest.fn()); +jest.mock('uuid', () => ({ v4: jest.fn() })); jest.mock('../../src/persistence', () => ({ removeItem: jest.fn(),