Skip to content

Commit 84b0dc8

Browse files
authored
Merge pull request #5 from arushsaxena1998/DOT-936
Adding sample for running storybook tests on a docker container
2 parents ce91f9c + 23619fd commit 84b0dc8

File tree

3 files changed

+63
-1
lines changed

3 files changed

+63
-1
lines changed

Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Use an official Node runtime as a parent image
2+
FROM node:18.15.0-alpine
3+
4+
# Set the working directory to /app
5+
WORKDIR /
6+
7+
# Copy the package.json and package-lock.json files to the container
8+
COPY package*.json ./
9+
10+
# Install dependencies
11+
12+
RUN npm i -g @lambdatest/smartui-storybook
13+
RUN npm install
14+
RUN apk add --no-cache \
15+
chromium \
16+
nss \
17+
freetype \
18+
harfbuzz \
19+
ca-certificates \
20+
ttf-freefont \
21+
&& rm -rf /var/cache/*
22+
23+
24+
# Copy the entire project directory to the container
25+
COPY . .
26+
27+
# Set environment variable
28+
29+
ENV PROJECT_TOKEN=<ProjectToken>
30+
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
31+
ENV PUPPETEER_EXECUTABLE_PATH /usr/bin/chromium-browser
32+
33+
# Build the Storybook static files
34+
RUN npm run build-storybook
35+
36+
# Set the command to run when the container starts
37+
CMD ["smartui", "storybook", "./storybook-static","--config",".smartui.json"]

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
1. Clone this repository
66
```
7-
git clone https://github.com/pinanks/smartui-storybook.git
7+
git clone https://github.com/LambdaTest/smartui-storybook-sample
88
```
99
1010
2. Change directory to the downloaded git repo and install packages
@@ -16,3 +16,27 @@
1616
```
1717
npm run storybook
1818
```
19+
20+
## Running SmartUI storybook tests on a Docker container.
21+
22+
1. Clone this repository
23+
```
24+
git clone https://github.com/LambdaTest/smartui-storybook-sample
25+
```
26+
2. Navigate to project directory
27+
```
28+
cd smartui-storybook-sample
29+
```
30+
3. Create SmartUI Config JSON
31+
```
32+
smartui config create .smartui.json
33+
```
34+
4. Create a docker Image
35+
```
36+
docker build -t <image_name> .
37+
```
38+
5. Run a Docker container and test in it
39+
```
40+
docker run -e PROJECT_TOKEN="your_project_token" <image_name>
41+
```
42+

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
]
4949
},
5050
"devDependencies": {
51+
"@lambdatest/smartui-storybook": "^1.1.3",
5152
"@storybook/addon-actions": "^6.5.16",
5253
"@storybook/addon-essentials": "^6.5.16",
5354
"@storybook/addon-interactions": "^6.5.16",

0 commit comments

Comments
 (0)