Skip to content

Commit

Permalink
chore(test): add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushmanchhabra committed Apr 6, 2024
1 parent f9e00b6 commit b2bff86
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,17 @@ jobs:
- run: npm -v
- run: npm ci
- run: npm run lint

test:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: volta-cli/action@v4
- run: npm i
- run: npm link
- run: |
cd ./tests/fixtures/app
npm i
- run: npm test
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"description": "Updates Volta config in package.json so Node match's what your NW.js version uses",
"scripts": {
"lint": "eslint --ext .js --config=.eslintrc.cjs .eslintrc.cjs",
"fix": "eslint --fix --ext .js --config=.eslintrc.cjs .eslintrc.cjs"
"fix": "eslint --fix --ext .js --config=.eslintrc.cjs .eslintrc.cjs",
"test": "vitest run --pool=forks"
},
"devDependencies": {
"@babel/eslint-parser": "^7.23.3",
Expand Down
10 changes: 10 additions & 0 deletions tests/fixtures/app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "demo",
"private": true,
"scripts": {
"start": "base-volta-off-of-nwjs"
},
"devDependencies": {
"nw": "0.86.0-1"
}
}
18 changes: 18 additions & 0 deletions tests/specs/cli.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import fs from 'node:fs';
import path from 'node:path';
import child_process from 'node:child_process';
import process from 'node:process';

import { test, expect } from 'vitest';

test('cli works', async function () {
process.chdir('tests/fixtures/app');
child_process.execSync('npm start');

const NodeManifestPath = path.resolve('package.json');
const NodeManifestBuffer = await fs.promises.readFile(NodeManifestPath);
const NodeManifest = JSON.parse(NodeManifestBuffer.toString());
const NodeVersion = NodeManifest.volta.node;

expect(NodeVersion).toBe('21.1.0');
});

0 comments on commit b2bff86

Please sign in to comment.