Skip to content

Commit ee26967

Browse files
authored
Merge branch 'dev' into hubspot-custom-properties-and+caching
2 parents 42d1746 + 68cb6cd commit ee26967

File tree

10 files changed

+3048
-224
lines changed

10 files changed

+3048
-224
lines changed

.github/workflows/nodejs.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ jobs:
1212
runs-on: ubuntu-latest
1313

1414
steps:
15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
1616
- name: Use Node.js 18.x
1717
uses: actions/setup-node@v4
1818
with:
1919
node-version: 18.x
20+
cache: 'npm'
2021
- name: Install dependencies
2122
run: npm ci
2223
- name: Run lint
2324
run: npm run lint
24-
25-
# - name: Run unit tests
26-
# run: npm run test-unit
25+
- name: Run unit tests
26+
run: npm run test-unit

.github/workflows/sonar.yml

+13
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,26 @@ jobs:
1515
- uses: actions/checkout@v4
1616
with:
1717
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
18+
- name: Set up Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
# our sonarqube server doesn't like node 20
22+
node-version: '18'
23+
cache: 'npm'
24+
- name: Install dependencies
25+
run: npm install
26+
- name: Run unit tests and coverage
27+
run: npm run test-unit-coverage
1828
- name: SonarQube Scan
1929
uses: SonarSource/[email protected]
2030
with:
2131
args: >
2232
-Dsonar.projectKey=clientIO_appmixer-connectors_AY7J_O6GZsPR2eThxIf0
2333
-Dsonar.sources=src
34+
-Dsonar.tests=test
35+
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
2436
-Dsonar.exclusions=*/test/**
37+
-Dsonar.coverage.exclusions=node_modules/**,test/**
2538
env:
2639
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
2740
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ tags.lock
1717
.vscode
1818
*~*
1919
.env.local
20+
coverage/
21+
.nyc_output/

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,20 @@
11
# appmixer-connectors
22
Appmixer Connectors
3+
4+
## Test
5+
In the `test` directory, you can find the test files for the connectors. They are not exhaustive as there is another set of tests that are not public.
6+
7+
### Running the tests
8+
```sh
9+
npm run test-unit
10+
```
11+
12+
### Appmixer stub
13+
In `test/utils.js` you can find a stub for the Appmixer API. It is supposed to emulate all the advanced features of the Appmixer engine like sending messages, doing HTTP requests, using cache, etc. It is not a complete implementation of the Appmixer API, but it is enough to test the connectors. You can use it to test your connectors without having to run the Appmixer engine.
14+
15+
These tests run for each PR. They are also integrated into SonarQube analysis which is run on each commit to `dev` branch.
16+
17+
### What to test
18+
Rule of thumb:
19+
- a `receive` function in a component should be tested if it has any logic in it (caching, timeouts, bulk processing). If it is just a pass-through, it does not need to be tested.
20+
- a `routes.js` file should be tested if used for more complex tasks. For example processing incoming webhooks.

0 commit comments

Comments
 (0)