Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint',
sourceType: 'module'
sourceType: 'module',
ecmaVersion: 2018
},
extends: [
'@nuxtjs'
]
'prettier'
],
plugins: ['prettier', 'vue'],
}
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm test
33 changes: 18 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,30 @@
"main": "lib/module.js",
"scripts": {
"dev": "nuxt example",
"lint": "eslint --ext .js,.vue .",
"lint": "eslint --ext .js, lib/module.js",
"release": "yarn test && standard-version && git push --follow-tags && yarn publish",
"test": "yarn lint && jest"
"test": "yarn lint && jest",
"prepare": "husky install"
},
"dependencies": {
"@tryghost/content-api": "^1.4.0"
"@tryghost/content-api": "^1.6.0"
},
"devDependencies": {
"@babel/core": "latest",
"@babel/preset-env": "latest",
"@commitlint/cli": "latest",
"@commitlint/config-conventional": "latest",
"@nuxtjs/eslint-config": "latest",
"@nuxtjs/module-test-utils": "latest",
"@commitlint/cli": "^16.2.1",
"@commitlint/config-conventional": "^16.2.1",
"@nuxtjs/eslint-config": "^8.0.0",
"babel-eslint": "latest",
"babel-jest": "^25.4.0",
"eslint": "latest",
"husky": "latest",
"jest": "^25.4.0",
"nuxt-edge": "^2.13.0-26465775.85383688",
"standard-version": "latest"
"babel-jest": "^27.4.6",
"eslint": "^8.9.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-vue": "^8.4.1",
"husky": "^8.0.0",
"jest": "^27.4.7",
"nuxt": "^2.15.8",
"request": "^2.88.2",
"request-promise-native": "^1.0.9",
"standard-version": "^9.3.2"
},
"publishConfig": {
"access": "public"
Expand Down
40 changes: 30 additions & 10 deletions test/module.test.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
const { setup, loadConfig, get } = require('@nuxtjs/module-test-utils')
const { Nuxt, Builder } = require('nuxt');
const config = require('../example/nuxt.config.js');
const request = require('request-promise-native');

const url = path => `http://localhost:3000${path}`;
const get = path => request(url(path));

describe('nuxtjs-ghost', () => {
let nuxt
let nuxt;
let addTemplate;

beforeAll(async () => {
({ nuxt } = (await setup(loadConfig(__dirname, '../../example'))))
}, 60000)
nuxt = new Nuxt(config);

addTemplate = nuxt.moduleContainer.addTemplate = jest.fn(nuxt.moduleContainer.addTemplate);

await new Builder(nuxt).build();
await nuxt.listen(3000);
}, 60000);

afterAll(async () => {
await nuxt.close()
})
await nuxt.close();
});

test('SSR mode', async () => {
const html = await get('/');
expect(html).toContain('Works!');
});

test('SPA mode', async () => {
const window = await nuxt.renderAndGetWindow(url('/'));

test('render', async () => {
const html = await get('/')
expect(html).toContain('Works!')
})
window.onNuxtReady(() => {
const html = window.document.body.innerHTML;
expect(html).toContain('Works!');
});
});
})
Loading