Skip to content

Commit

Permalink
improve CI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michalzaq12 committed Jul 3, 2019
1 parent 894431a commit 5a2f68f
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 79 deletions.
27 changes: 25 additions & 2 deletions meta.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,58 @@
'use strict';

const isTest = process.env.NODE_ENV === 'test';
const TEST_SUITE = process.env.TEST_SUITE;

if(isTest && TEST_SUITE === undefined){
throw new Error('You must provide TEST_SUITE env variable');
}
const scenario = isTest && require(`./tests/scenarios`)[TEST_SUITE];

module.exports = {
//https://github.com/vuejs-templates/webpack/blob/develop/meta.js
metalsmith: {
before: (metalsmith) =>{
Object.assign(
metalsmith.metadata(),
{isCIServer: process.env.CI}
{
isCIServer: process.env.CI,
isNotTest: !isTest
},
isTest ? scenario : {}
)
}
},
prompts: {
name: {
when: 'isNotTest',
type: 'string',
required: true,
message: 'Application Name',
default: 'your-app'
},
appid: {
when: 'isNotTest',
type: 'string',
required: true,
message: 'Application Id',
default: 'com.example.yourapp'
},
appver: {
when: 'isNotTest',
type: 'string',
required: true,
message: 'Application Version',
default: '0.0.1'
},
description: {
when: 'isNotTest',
type: 'string',
required: false,
message: 'Project description',
default: 'An electron-nuxt project'
},
cssFramework: {
when: 'isNotTest',
type: 'list',
message: 'Select which ui-components framework install',
choices: [
Expand All @@ -61,6 +79,7 @@ module.exports = {
]
},
cssPreprocessor: {
when: 'isNotTest',
type: 'list',
message: 'Select which css pre-processor install',
choices: [
Expand All @@ -87,6 +106,7 @@ module.exports = {
]
},
iconSet: {
when: 'isNotTest',
type: 'list',
message: 'Select which icon set install',
choices: [
Expand All @@ -108,13 +128,14 @@ module.exports = {
]
},
eslint: {
when: 'isNotTest',
type: 'confirm',
require: true,
message: 'Use linting with ESLint?',
default: false
},
eslintConfig: {
when: 'eslint',
when: 'isNotTest && eslint',
type: 'list',
message: 'Which ESLint config would you like to use?',
choices: [
Expand All @@ -136,12 +157,14 @@ module.exports = {
]
},
unit: {
when: 'isNotTest',
type: 'confirm',
message: 'Set up unit testing with vue-test-utils + AVA?',
required: true,
default: false
},
e2e: {
when: 'isNotTest',
type: 'confirm',
message: 'Set up end-to-end testing with Spectron + AVA?',
require: true,
Expand Down
File renamed without changes.
11 changes: 3 additions & 8 deletions tests/init.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
#!/bin/bash
set -e

cd "$PWD/tests"

# Clean up dir if exist
if [[ -d "$1" ]]; then rm -Rf $1; fi

# Scaffold boilerplate with given templateName
node scaffold.js "$1"
# Scaffold boilerplate
printf "Yes" | vue init . ./generated_template
sleep .5


# Install dependencies
cd "$PWD/builds/$1"
cd "$PWD/generated_template"
npm install


Expand Down
45 changes: 0 additions & 45 deletions tests/scaffold.js

This file was deleted.

46 changes: 22 additions & 24 deletions tests/scenarios.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,54 @@
const CONFIRM = '\n';
const DEFAULT_VALUE = '\n';
const DOWN_ARROW = '\u001b[B';
const NONE = 'none';

const defaultValues = {
name: DEFAULT_VALUE,
appid: DEFAULT_VALUE,
appver: DEFAULT_VALUE,
description: DEFAULT_VALUE,
cssFramework: DEFAULT_VALUE,
cssPreprocessor: DEFAULT_VALUE,
iconSet: DEFAULT_VALUE,
eslint: DEFAULT_VALUE,
eslintConfig: DEFAULT_VALUE,
unit: DEFAULT_VALUE,
e2e: DEFAULT_VALUE,
author: DEFAULT_VALUE
name: 'your-app',
appid: 'com.example.yourapp',
appver: '0.0.1',
description: 'An electron-nuxt project',
cssFramework: NONE,
cssPreprocessor: NONE,
iconSet: NONE,
eslint: false,
eslintConfig: NONE,
unit: false,
e2e: false,
author: 'test-bot'
};

const scenarios = {
default: defaultValues,
eslint: {
...defaultValues,
eslint: CONFIRM
eslint: true
},
testing: {
...defaultValues,
unit: CONFIRM,
e2e: CONFIRM
unit: true,
e2e: true
},
sass: {
...defaultValues,
cssPreprocessor: DOWN_ARROW + CONFIRM
cssPreprocessor: 'sass'
},
less: {
...defaultValues,
cssPreprocessor: DOWN_ARROW + DOWN_ARROW + CONFIRM
cssPreprocessor: 'less'
},
stylus: {
...defaultValues,
cssPreprocessor: DOWN_ARROW + DOWN_ARROW + DOWN_ARROW + CONFIRM
cssPreprocessor: 'stylus'
},
vuetify: {
...defaultValues,
cssFramework: DOWN_ARROW + CONFIRM
cssFramework: 'vuetify'
},
buefy: {
...defaultValues,
cssFramework: DOWN_ARROW + DOWN_ARROW + CONFIRM
cssFramework: 'buefy'
},
element: {
...defaultValues,
cssFramework: DOWN_ARROW + DOWN_ARROW + DOWN_ARROW + CONFIRM
cssFramework: 'element'
}
};

Expand Down

0 comments on commit 5a2f68f

Please sign in to comment.