Skip to content

Commit

Permalink
fix: Deploy tests with built artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
jdrydn committed Oct 24, 2023
1 parent 42950e1 commit 02a20f0
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 12 deletions.
3 changes: 2 additions & 1 deletion vue3-express-spa-ts/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@
}
},
{
"files": ["test/**", "**/*.test.ts", "**/test/**"],
"files": ["test/**", "**/*.test.js", "**/*.test.ts", "**/test/**"],
"env": { "mocha": true },
"plugins": ["mocha"],
"rules": {
"global-require": "off",
"padded-blocks": "off",
"prefer-arrow-callback": "off",
"func-names": "off",
Expand Down
27 changes: 27 additions & 0 deletions vue3-express-spa-ts/deploy/server/app.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const supertest = require('supertest');

describe('deploy/server', () => describe('app', () => {
const app = require('./app');

it('should return early for GET /status', async () => {
await supertest(app)
.get('/status')
.expect(200)
.expect('Content-Type', 'text/plain; charset=utf-8')
.expect(':+1:');
});

it('should return for GET /api', async () => {
await supertest(app)
.get('/api')
.expect(200)
.expect({ message: 'Hello, world' });
});

it('should return for GET /', async () => {
await supertest(app)
.get('/')
.expect(200)
.expect('Content-Type', 'text/html; charset=utf-8');
});
}));
8 changes: 4 additions & 4 deletions vue3-express-spa-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"lint": "eslint . --ext .js,.ts",
"postinstall": "./install.sh",
"start": "npm --prefix ./deploy/server start",
"test:src": "mocha ./src/*/{,!(node_modules)/**}/*.test.{,+(js|ts)}",
"test:deploy": "mocha ./deploy/*/{,!(node_modules)/**}/*.test.{,+(js|ts)}"
"test:src": "NODE_ENV=testing mocha './src/*/{,!(node_modules)/**}/*.test.{,+(js|ts)}'",
"test:deploy": "NODE_ENV=testing mocha './deploy/*/{,!(node_modules)/**}/*.test.{,+(js|ts)'}"
},
"repository": "https://github.com/someimportantcompany/starter-templates",
"bugs": "https://github.com/someimportantcompany/starter-templates/issues",
Expand Down Expand Up @@ -39,8 +39,8 @@
"typescript": "^5.2.2"
},
"engines": {
"node": "16.x",
"npm": "8.x"
"node": ">=16.x",
"npm": ">=8.x"
},
"mocha": {
"exit": true,
Expand Down
4 changes: 3 additions & 1 deletion vue3-express-spa-ts/src/backend/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ const serializers = {

const logger = bunyan.createLogger({
name: process.env.LOG_NAME || 'vue3-express-spa-ts',
level: process.env.LOG_LEVEL as LogLevel || (process.env.NODE_ENV === 'production' ? 'info' : 'debug'),
level: process.env.LOG_LEVEL as LogLevel
?? (process.env.NODE_ENV === 'testing' ? 61 : undefined)
?? (process.env.NODE_ENV === 'production' ? 'info' : 'debug'),
serializers,
});

Expand Down
3 changes: 2 additions & 1 deletion vue3-express-ssr-ts/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@
}
},
{
"files": ["test/**", "**/*.test.ts", "**/test/**"],
"files": ["test/**", "**/*.test.js", "**/*.test.ts", "**/test/**"],
"env": { "mocha": true },
"plugins": ["mocha"],
"rules": {
"global-require": "off",
"padded-blocks": "off",
"prefer-arrow-callback": "off",
"func-names": "off",
Expand Down
27 changes: 27 additions & 0 deletions vue3-express-ssr-ts/deploy/server/app.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const supertest = require('supertest');

describe('deploy/server', () => describe('app', () => {
const app = require('./app');

it('should return early for GET /status', async () => {
await supertest(app)
.get('/status')
.expect(200)
.expect('Content-Type', 'text/plain; charset=utf-8')
.expect(':+1:');
});

it('should return for GET /api', async () => {
await supertest(app)
.get('/api')
.expect(200)
.expect({ message: 'Hello, world' });
});

it('should return for GET /', async () => {
await supertest(app)
.get('/')
.expect(200)
.expect('Content-Type', 'text/html; charset=utf-8');
});
}));
8 changes: 4 additions & 4 deletions vue3-express-ssr-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"lint": "eslint . --ext .js,.ts",
"postinstall": "./install.sh",
"start": "npm --prefix ./deploy/server start",
"test:src": "mocha './src/*/{,!(node_modules)/**}/*.test.{,+(js|ts)}'",
"test:deploy": "mocha './deploy/*/{,!(node_modules)/**}/*.test.{,+(js|ts)}'"
"test:src": "NODE_ENV=testing mocha './src/*/{,!(node_modules)/**}/*.test.{,+(js|ts)}'",
"test:deploy": "NODE_ENV=testing mocha './deploy/*/{,!(node_modules)/**}/*.test.{,+(js|ts)}'"
},
"repository": "https://github.com/someimportantcompany/starter-templates",
"bugs": "https://github.com/someimportantcompany/starter-templates/issues",
Expand Down Expand Up @@ -39,8 +39,8 @@
"typescript": "^5.2.2"
},
"engines": {
"node": "16.x",
"npm": "8.x"
"node": ">=16.x",
"npm": ">=8.x"
},
"mocha": {
"exit": true,
Expand Down
4 changes: 3 additions & 1 deletion vue3-express-ssr-ts/src/backend/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ const serializers = {

const logger = bunyan.createLogger({
name: process.env.LOG_NAME || 'vue3-express-ssr-ts',
level: process.env.LOG_LEVEL as LogLevel || (process.env.NODE_ENV === 'production' ? 'info' : 'debug'),
level: process.env.LOG_LEVEL as LogLevel
?? (process.env.NODE_ENV === 'testing' ? 61 : undefined)
?? (process.env.NODE_ENV === 'production' ? 'info' : 'debug'),
serializers,
});

Expand Down

0 comments on commit 02a20f0

Please sign in to comment.