Skip to content

Commit bd95796

Browse files
committed
Add integration testing for examples
1 parent 562e619 commit bd95796

File tree

14 files changed

+1336
-42
lines changed

14 files changed

+1336
-42
lines changed

.gitlab-ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
script:
1414
- npm run ci
1515

16+
stages:
17+
- build
18+
- test
19+
- integration
20+
1621
cache:
1722
paths:
1823
- node_modules/
@@ -66,3 +71,14 @@ cache:
6671
extends: .test_default
6772
dependencies:
6873
- node build v15
74+
75+
"example integration testing":
76+
stage: integration
77+
image: node:14-alpine
78+
dependencies:
79+
- node build v14
80+
before_script:
81+
- "npx ts-node test/util/server.ts &"
82+
script:
83+
- "cd examples/imdb-api-react && yarn && yarn test; cd ../.."
84+
- "cd examples/imdb-api-node && npm install && node index.js; cd ../.."

examples/imdb-api-node/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const imdb = require("imdb-api");
22

33
(async function() {
4-
const movie = await imdb.get({name: "The Toxic Avenger"}, {apiKey: "your api key here"});
4+
const movie = await imdb.get({name: "Toxic Avenger"}, {apiKey: "your api key here", baseURL: "http://localhost:3000"});
55
console.log(movie);
66
})()

examples/imdb-api-react/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,6 @@
4141
"last 1 firefox version",
4242
"last 1 safari version"
4343
]
44-
}
44+
},
45+
"proxy": "http://localhost:3000/"
4546
}
-3.78 KB
Binary file not shown.
-5.22 KB
Binary file not shown.
-9.44 KB
Binary file not shown.

examples/imdb-api-react/public/manifest.json

Lines changed: 0 additions & 25 deletions
This file was deleted.

examples/imdb-api-react/public/robots.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/imdb-api-react/src/App.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import React from 'react';
22
import { render, screen } from '@testing-library/react';
33
import App from './App';
44

5-
test('renders learn react link', () => {
5+
test('renders learn react link', async () => {
66
render(<App />);
7-
const linkElement = screen.getByText(/learn react/i);
7+
const linkElement = await screen.findByText(/toxic/i);
88
expect(linkElement).toBeInTheDocument();
99
});

examples/imdb-api-react/src/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class App extends Component<MyProps, MyState> {
1414

1515
async componentDidMount() {
1616
try {
17-
const results = await imdb.get({name: 'The Toxic Avenger'}, {apiKey: 'use your api key here'});
17+
const results = await imdb.get({name: 'Toxic Avenger'}, {apiKey: 'use your api key here', baseURL: "http://localhost:3000"});
1818
this.setState({movie: results, error: ""});
1919
} catch (e) {
2020
this.setState({movie: undefined, error: e.message});
@@ -24,6 +24,7 @@ class App extends Component<MyProps, MyState> {
2424
render() {
2525
return (
2626
<div className="top">
27+
<h1>Movie</h1>
2728
<div className="content">
2829
{this.state.movie?.title}
2930
</div>

0 commit comments

Comments
 (0)