How to access running webserver inside gitlab CI? Error: net::ERR_CONNECTION_REFUSED

I have a simple task. Is a basic react app.
When I run “npm start” it starts the server at localhost:3000 then I can test the content there.
But when I try to access it in my test stage I get network error

Error: net::ERR_CONNECTION_REFUSED at http://localhost:3000

my .gitlab-ci is basically:

image:
    name: backstopjs/backstopjs:latest
    entrypoint: [""]

stages:
  - build
  - test
  
cache:
  paths:
  - node_modules/

build:
  stage: build
  script:
    - npm install
    - npm start &

test:
  stage: test
  script:
    - npm run bs:test

hey. did you ever find out about this? I have a similar issue, the solution to which can be this.

Hi!
Yes. In my case, it should be done in only one stage. And using docker-in-docker, something like:

image: 
  name: gitlab/dind

services:
  - docker:dind

stages:
  - test

cache:
  paths:
  - node_modules/

test:
  stage: test
  script:
    - docker-compose up -d
    - EXECUTE_OTHER_COMMANDS_IN_JUST_CREATED_DOCKER