Skip to content
This repository was archived by the owner on Feb 18, 2023. It is now read-only.

Commit cf9f5b4

Browse files
committed
initialize test suite
1 parent 734c100 commit cf9f5b4

File tree

10 files changed

+16502
-4194
lines changed

10 files changed

+16502
-4194
lines changed

.github/workflows/main.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
branches: [ main ]
1111

1212
jobs:
13-
build-and-test:
13+
build:
1414

1515
runs-on: ubuntu-latest
1616

@@ -27,16 +27,12 @@ jobs:
2727
node-version: ${{ matrix.node-version }}
2828

2929
- name: Install dependencies
30-
run: npm install
30+
run: npm ci
3131

3232
- name: Build project
3333
run: npm run build
3434

35-
# And create some tests
36-
- name: Perform tests
37-
run: npm test
38-
39-
check-lint-format:
35+
check-lint-format-test:
4036
runs-on: ubuntu-20.04
4137

4238
steps:
@@ -59,4 +55,7 @@ jobs:
5955
run: npm run type-check
6056

6157
- name: Markdownlint
62-
run: npm run markdownlint
58+
run: npm run markdownlint
59+
60+
- name: Perform tests
61+
run: npm run test

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
npm run fmt:check && npm run lint
4+
npm run fmt:check && npm run lint && npm run depcheck

__tests__/provider.test.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { render } from '@testing-library/react'
2+
import '@testing-library/jest-dom'
3+
import { SentryProvider } from '../src/SentryProvider'
4+
5+
describe('<SentryProvider />', () => {
6+
test('script tag is correctly rendered', async () => {
7+
const sentryConfig = {
8+
dsn: process.env.REACT_APP_SENTRY_DSN ?? '',
9+
debug: true,
10+
environment: 'development',
11+
release: 'test-release',
12+
sampleRate: 1.0
13+
}
14+
15+
render(
16+
<SentryProvider
17+
children={<></>}
18+
url="https://browser.sentry-cdn.com/6.16.1/bundle.min.js"
19+
integrity="sha384-WkFzsrcXKeJ3KlWNXojDiim8rplIj1RPsCbuv7dsLECoXY8C6Cx158CMgl+O+QKW"
20+
config={sentryConfig}
21+
scope
22+
/>
23+
)
24+
25+
const script = document.querySelectorAll(`[data-testid*="sentry"]`)
26+
expect(script.length).toBe(1)
27+
})
28+
})

babel.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Used for testing purpose
2+
module.exports = {
3+
presets: [
4+
['@babel/preset-env', {targets: {node: 'current'}}],
5+
'@babel/preset-typescript',
6+
],
7+
};

0 commit comments

Comments
 (0)