feat: add testing capabilities
This commit is contained in:
parent
7d5b3c4ac7
commit
b77c0a57cc
|
@ -12,3 +12,4 @@ db
|
||||||
database.sqlite-journal
|
database.sqlite-journal
|
||||||
docker/nginx/chibisafe.moe.conf
|
docker/nginx/chibisafe.moe.conf
|
||||||
docker-compose.config.yml
|
docker-compose.config.yml
|
||||||
|
/coverage
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
function isBabelLoader(caller) {
|
||||||
|
return caller && caller.name === 'babel-loader';
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = function(api) {
|
||||||
|
if (api.env('test') && !api.caller(isBabelLoader)) {
|
||||||
|
return {
|
||||||
|
presets: [
|
||||||
|
[
|
||||||
|
'@babel/preset-env',
|
||||||
|
{
|
||||||
|
targets: {
|
||||||
|
node: 'current'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
};
|
|
@ -0,0 +1,9 @@
|
||||||
|
module.exports = {
|
||||||
|
moduleFileExtensions: ['js', 'json', 'vue'],
|
||||||
|
moduleDirectories: ['node_modules'],
|
||||||
|
transform: {
|
||||||
|
'^.+\\.js$': '<rootDir>/node_modules/babel-jest',
|
||||||
|
'.*\\.(vue)$': '<rootDir>/node_modules/vue-jest'
|
||||||
|
},
|
||||||
|
transformIgnorePatterns: ['/node_modules/(?!vue)']
|
||||||
|
};
|
File diff suppressed because it is too large
Load Diff
20
package.json
20
package.json
|
@ -17,7 +17,11 @@
|
||||||
"seed": "knex seed:run",
|
"seed": "knex seed:run",
|
||||||
"api": "node src/api/structures/Server",
|
"api": "node src/api/structures/Server",
|
||||||
"update": "git pull && npm install && npm run migrate && npm run build && npm run restart",
|
"update": "git pull && npm install && npm run migrate && npm run build && npm run restart",
|
||||||
"restart": "pm2 restart lolisafe"
|
"restart": "pm2 restart lolisafe",
|
||||||
|
"test:vue": "jest --testPathPattern=src/site",
|
||||||
|
"test:api": "jest --testPathPattern=src/tests/api",
|
||||||
|
"test:e2e": "jest --testPathPattern=src/tests/e2e",
|
||||||
|
"tests": "npm run test:api && npm run test:vue && npm run test:e2e"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -79,18 +83,28 @@
|
||||||
"vuebar": "^0.0.20"
|
"vuebar": "^0.0.20"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@babel/core": "^7.12.10",
|
||||||
|
"@babel/preset-env": "^7.12.11",
|
||||||
|
"@vue/test-utils": "^1.1.2",
|
||||||
"autoprefixer": "^9.4.7",
|
"autoprefixer": "^9.4.7",
|
||||||
|
"axios": "^0.21.1",
|
||||||
|
"babel-core": "^7.0.0-bridge.0",
|
||||||
"babel-eslint": "^10.0.1",
|
"babel-eslint": "^10.0.1",
|
||||||
|
"babel-jest": "^26.6.3",
|
||||||
"cross-env": "^5.2.0",
|
"cross-env": "^5.2.0",
|
||||||
"eslint": "^7.16.0",
|
"eslint": "^7.17.0",
|
||||||
"eslint-config-aqua": "^7.3.0",
|
"eslint-config-aqua": "^7.3.0",
|
||||||
"eslint-import-resolver-nuxt": "^1.0.1",
|
"eslint-import-resolver-nuxt": "^1.0.1",
|
||||||
"eslint-plugin-vue": "^5.2.1",
|
"eslint-plugin-vue": "^5.2.1",
|
||||||
|
"jest": "^26.6.3",
|
||||||
|
"jest-serializer-vue": "^2.0.2",
|
||||||
"node-sass": "^5.0.0",
|
"node-sass": "^5.0.0",
|
||||||
"nodemon": "^1.19.3",
|
"nodemon": "^1.19.3",
|
||||||
"postcss-css-variables": "^0.11.0",
|
"postcss-css-variables": "^0.11.0",
|
||||||
"postcss-nested": "^3.0.0",
|
"postcss-nested": "^3.0.0",
|
||||||
"sass-loader": "^10.1.0"
|
"puppeteer": "^5.5.0",
|
||||||
|
"sass-loader": "^10.1.0",
|
||||||
|
"vue-jest": "^3.0.7"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"extends": [
|
"extends": [
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
/* eslint-disable no-undef */
|
||||||
|
import { shallowMount, createLocalVue } from '@vue/test-utils';
|
||||||
|
import Component from './Footer.vue';
|
||||||
|
import Vuex from 'vuex';
|
||||||
|
|
||||||
|
const localVue = createLocalVue();
|
||||||
|
localVue.use(Vuex);
|
||||||
|
|
||||||
|
describe('Footer.vue', () => {
|
||||||
|
const store = new Vuex.Store({
|
||||||
|
getters: {
|
||||||
|
'auth/isLoggedIn': () => false
|
||||||
|
},
|
||||||
|
state: {
|
||||||
|
config: {}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should render chibisafe as the instance title', () => {
|
||||||
|
const wrapper = shallowMount(Component, { store, localVue });
|
||||||
|
|
||||||
|
const title = wrapper.find('h4');
|
||||||
|
expect(title.text()).toBe('chibisafe');
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,12 @@
|
||||||
|
/* eslint-disable no-undef */
|
||||||
|
import { axios } from '../utils';
|
||||||
|
|
||||||
|
// This should never succeed as we are not passing a token. We are expecting a 401
|
||||||
|
test('Verify token', async () => {
|
||||||
|
try {
|
||||||
|
await axios.get('/api/verify');
|
||||||
|
expect(true).toBe(false);
|
||||||
|
} catch (err) {
|
||||||
|
expect(err.response.status).toBe(401);
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,20 @@
|
||||||
|
/* eslint-disable no-undef */
|
||||||
|
const puppeteer = require('puppeteer');
|
||||||
|
|
||||||
|
test('Check the logo renders', async () => {
|
||||||
|
const browser = await puppeteer.launch({
|
||||||
|
headless: true
|
||||||
|
});
|
||||||
|
const page = await browser.newPage();
|
||||||
|
|
||||||
|
await page.goto('http://localhost:5000', {
|
||||||
|
timeout: 45000,
|
||||||
|
waitUntil: ['networkidle2']
|
||||||
|
});
|
||||||
|
|
||||||
|
// Check the logo exists
|
||||||
|
const logo = await page.waitForSelector('.logoContainer');
|
||||||
|
await browser.close();
|
||||||
|
|
||||||
|
expect(logo).toBeTruthy();
|
||||||
|
});
|
|
@ -0,0 +1,11 @@
|
||||||
|
const axios = require('axios');
|
||||||
|
const instance = axios.create({
|
||||||
|
baseURL: 'http://localhost:5000',
|
||||||
|
headers: {
|
||||||
|
common: {
|
||||||
|
accept: 'application/vnd.chibisafe.json'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports.axios = instance;
|
Loading…
Reference in New Issue