Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
blob: 6ae46737ac680ce0c4c6f59094c557aef6c4e557 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
## Install dev server packages

    docker run --rm -w /app -v $PWD:/app -u $(id -u):$(id -u) node npm install

## Start the dev server

    docker run --rm --init -it -v $PWD:/usr/src/app -p 8080:8080 btroops

or, run the start script

    ./run-start

Visit `localhost:8080` to view.

## Run a test

You need chrome and chromedriver installed to run the integration tests. The Dockerfile builds an image that does that. Then run the test with that image.

`--network host` gives the container internet access. Necessary if tests make outside requests.

    docker run --rm -it -v $PWD:/usr/src/app --network host btroops node google_test

TODO add firefox and geckodriver

The container can access the outside without setting a port or a network. The network or port is only necessary when wanting to connect the host machine to the docker container. You can run a test that spawns a test server and uses the webdriver to load the page like this:

    docker run --rm -it -v $PWD:/usr/src/app btroops npm run test:integ

or, run the test script

    ./run-test

## Rough way to save the SVG map generated by JavaScript client-side

    const XMLS = new XMLSerializer();
    const svg_xmls = XMLS.serializeToString(svg);
    let bl = new Blob([svg_xmls], {type: "text/html" });
    let a = document.createElement("a");
    a.href = URL.createObjectURL(bl);
    a.download = "map.svg";
    a.hidden = true;
    document.body.appendChild(a);
    a.innerHTML = "something random - nobody will see this, it doesn't matter what you put here";
    a.click()