Skip to content

Commit

Permalink
test: fix failing test suites
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 committed Aug 9, 2020
1 parent 45940f9 commit d84fe6f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
33 changes: 26 additions & 7 deletions __e2e__/commands/add.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ describe('mevn add', () => {
[
`${DOWN}${DOWN}${DOWN}${ENTER}`, // Choose Nuxt.js
`${SPACE}${ENTER}`, // Opt for @nuxtjs/axios module
`${DOWN}${ENTER}`, // Choose spa as the rendering mode
`${DOWN}${ENTER}`, // Choose static as the deploy target
ENTER, // Choose universal as the rendering mode
ENTER, // Choose server as the deploy target
`Y${ENTER}`, // Requires server directory
],
tempDirPath,
Expand All @@ -41,33 +41,52 @@ describe('mevn add', () => {
// Invoke the add command
await runPromptWithAnswers(
['add'],
[ENTER, `${DOWN}${SPACE}${DOWN}${DOWN}${SPACE}${ENTER}`], // Choose @nuxtjs/pwa module and the vuex addon
[
ENTER,
`${DOWN}${SPACE}${DOWN}${DOWN}${DOWN}${SPACE}${DOWN}${DOWN}${DOWN}${DOWN}${SPACE}${ENTER}`,
], // Choose @nuxtjs/pwa, nuxt-oauth and @nuxtjs/storybook modules
genPath,
);

// nuxt.config.js
const nuxtConfig = require(path.join(clientPath, 'nuxt.config.js')).default;
expect(nuxtConfig.buildModules).toContain('@nuxtjs/pwa');
expect(nuxtConfig.modules).toContain('nuxt-oauth');
expect(nuxtConfig.buildModules).not.toContain('@nuxtjs/storybook');
expect(nuxtConfig.modules).toContain('@nuxtjs/axios');

// .mevnrc
const projectConfig = JSON.parse(
fs.readFileSync(path.join(genPath, '.mevnrc')),
);
expect(projectConfig.modules).toContain('pwa');
expect(projectConfig.modules).toContain('vuex');
expect(projectConfig.modules).toContain('axios');
['pwa', 'oauth', 'storybook', 'vuex', 'axios'].forEach((module) =>
expect(projectConfig.modules).toContain(module),
);
expect(projectConfig.isConfigured).toBe(true);

// package.json
const pkgJson = JSON.parse(
fs.readFileSync(path.join(clientPath, 'package.json')),
);
expect(pkgJson.dependencies['nuxt-oauth']).toBeTruthy();
expect(pkgJson.devDependencies['@nuxtjs/pwa']).toBeTruthy();
expect(pkgJson.devDependencies['@nuxtjs/storybook']).toBeTruthy();

// @nuxtjs/axios should be installed via mevn serve since it was opted at first
expect(pkgJson.devDependencies['@nuxtjs/axios']).not.toBeTruthy();

// vuex-store
const gitIgnoreContent = fs
.readFileSync(path.join(clientPath, '.gitignore'), 'utf8')
.split('\n');
expect(gitIgnoreContent.includes('.nuxt-storybook')).toBeTruthy();
expect(gitIgnoreContent.includes('storybook-static')).toBeTruthy();

const nuxtIgnoreContent = fs
.readFileSync(path.join(clientPath, '.nuxtignore'), 'utf8')
.split('\n');
expect(nuxtIgnoreContent.includes('**/*.stories.js')).toBeTruthy();

// vuex-store is activated via nuxt-oauth
expect(
fs.readFileSync(path.join(clientPath, 'store', 'index.js')),
).toBeTruthy();
Expand Down
1 change: 1 addition & 0 deletions __e2e__/commands/init.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ describe('mevn init', () => {
// .mevnrc
const projectConfigContent = {
name: 'my-app',
renderingMode: 'spa',
template: 'Nuxt.js',
modules: ['pwa', 'content'],
deployTarget: 'static',
Expand Down
2 changes: 1 addition & 1 deletion jest/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const runPromptWithAnswers = (args, answers, testPath) => {
setTimeout(() => {
process.stdin.write(answers[0]);
writeToStdin(answers.slice(1));
}, 2000);
}, 3000);
} else {
process.stdin.end();
}
Expand Down
2 changes: 1 addition & 1 deletion jest/setupE2eTests.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
jest.setTimeout(60000);
jest.setTimeout(240000);
2 changes: 1 addition & 1 deletion src/commands/basic/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ const addDeps = async (deps, { dev }) => {
// Update modules entry with the installed Nuxt.js modules
const installedNuxtModules = [].concat(modules, buildModules, addons);
if (
installedNuxtModules.includes('nuxt-oauth') &&
installedNuxtModules.includes('oauth') &&
!installedNuxtModules.includes('vuex')
) {
// Vuex Store is activated with nuxt-oauth
Expand Down

0 comments on commit d84fe6f

Please sign in to comment.