Skip to content

Commit

Permalink
test cucumber
Browse files Browse the repository at this point in the history
  • Loading branch information
rrfaria committed Apr 12, 2017
1 parent b461cc5 commit 131aa65
Show file tree
Hide file tree
Showing 15 changed files with 107 additions and 45 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $ npm install

### using the Cloudnary

Create your account on cloudnary and then make sure you did the fallow steps:
Create your account on cloudinary and then make sure you did the following steps:

* go to there : [https://cloudinary.com](https://cloudinary.com)

Expand Down
7 changes: 7 additions & 0 deletions features/app.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Feature: Teste open page
I will test the open page of app

Scenario: Try open the initial page
Given the initial page
And I have the content table in body
Then I should have a title "Projeto Crud - localStorage" on page
9 changes: 9 additions & 0 deletions features/step_definitions/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
let seleniumWebdriver = require('selenium-webdriver');
let {defineSupportCode} = require('cucumber');

defineSupportCode(function({Given, When, Then}) {
Given('the initial page', function() {
return this.driver.get('http://localhost:8080/');
});

});
13 changes: 13 additions & 0 deletions features/support/world.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require('chromedriver');
var seleniumWebdriver = require('selenium-webdriver');
var {defineSupportCode} = require('cucumber');

function CustomWorld() {
this.driver = new seleniumWebdriver.Builder()
.forBrowser('chrome')
.build();
}

defineSupportCode(function({setWorldConstructor}) {
setWorldConstructor(CustomWorld)
});
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"dev": "set NODE=dev && webpack-dev-server",
"prod": "npm run clean && set NODE_ENV=production && webpack -p",
"clean": "rimraf ./dist/*",
"test": "set NODE_ENV=test mocha --opts test/mocha.opts test/*.js",
"test": "mocha --opts test/mocha.opts test/**/*.js",
"testw": "mocha --opts test/mocha.opts test/**/*.js -w",
"behavior": "cucumber-js",
"test-tdd": "mocha --opts test/mocha.opts test/**/*.js",
"test2": "find ./ -name '*.test.js' | xargs mocha -R min -r babel/register",
"devtest": "webpack-dev-server --config webpack.tests.config.js"
},
Expand All @@ -24,18 +27,20 @@
"babel-preset-es2015": "^6.24.1",
"babel-register": "^6.24.1",
"chai": "^3.5.0",
"chromedriver": "^2.25.1",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.28.0",
"cucumber": "^1.3.2",
"extract-text-webpack-plugin": "^2.1.0",
"file-loader": "^0.11.1",
"html-webpack-plugin": "^2.28.0",
"mocha": "^3.2.0",
"mocha-loader": "^1.1.1",
"node-sass": "^4.5.2",
"postcss-loader": "^1.3.3",
"pug-html-loader": "^1.1.4",
"rimraf": "^2.6.1",
"sass-loader": "^6.0.3",
"selenium-webdriver": "^3.0.1",
"style-loader": "^0.16.1",
"supertest": "^3.0.0",
"uglify-js": "^2.8.22",
Expand Down
1 change: 1 addition & 0 deletions test/helpers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//it is a global settings
import suppertest from 'supertest';
import chai from 'chai';
import General from '../src/utils/general';
Expand Down
4 changes: 1 addition & 3 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<title>Title</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Fim do SEO do site -->
<link rel="stylesheet" href="../node_modules/mocha/mocha.css">
</head>
<body>
Expand All @@ -16,8 +15,7 @@
mocha.setup('bdd');
mocha.reporter('html');
</script>
<script src="MyLibrary.js"></script>
<script src="global-tests.js"></script>
<script src="should.be.a.buyndle.of.tests.js"></script>
<script>
mocha.run();
</script>
Expand Down
29 changes: 24 additions & 5 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
// This will search for files ending in .test.js and require them
// so that they are added to the webpack bundle
let context = require.context('.', true, /.+\.test\.js?$/);
context.keys().forEach(context);
module.exports = context;
describe ('Interface', ()=>{

describe ('Create Elements',()=>{
it ('should return 3 panels', () =>{
expect("1").to.equal("1");
});
it ('should add fields', () =>{
expect("1").to.equal("1");
})
});
describe ('Vallidate Masks',()=>{
it ('mask phone', () =>{
expect("1").to.equal("1");
});
it ('mask cpf', () =>{
expect("1").to.equal("1");
})
})
describe ('Check address field',()=>{
it ('load google place autocomplete', () =>{
expect("1").to.equal("1");
});
})
});
3 changes: 1 addition & 2 deletions test/mocha.opts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

--require babel-polyfill
--require test/helpers.js
--reporter spec
--compilers js:babel-core/register
--slow 5000
5 changes: 2 additions & 3 deletions test/utils/cloudnary.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import chai,{expect} from 'chai';
import cloudnary from 'src/utils/cloudnary';


describe('Cloudnay', ()=>{
it ('should send the image to server and execute or function',()=>{

expect("1").to.equal("1");
});

it ('should return response if status is between 200 and 300', ()=>{
Expand Down
14 changes: 14 additions & 0 deletions test/utils/elementSelector.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import $ from '../../src/utils/elementSelector';

describe('Element selector Class', ()=>{
//const table = document.getElementById('tablerows');
it ('should return a element by id',()=>{
//expect($.id(tablerows)).to.equal(table);
});

it ('show add event listener to multi element equals ', ()=>{

});


});
1 change: 1 addition & 0 deletions test/utils/general.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions test/utils/imputer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

18 changes: 18 additions & 0 deletions test/utils/lsManager.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
describe('LocalStorage', ()=>{
it ('should initialize elements on table if there something',()=>{
expect("1").to.equal("1");
});

it ('Should add new contact', ()=>{

});

it ('Should Edit contact', ()=>{

});

it ('Should Delete contact', ()=>{

});

});
36 changes: 7 additions & 29 deletions webpack.tests.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const CopyWebpackPlugin = require('copy-webpack-plugin');
const webpack = require('webpack');
const autoprefixer = require('autoprefixer');
const path = require("path");

module.exports = {
entry: 'mocha!./test/index.js',
entry: {
app: './test/index.js'
},
output: {
filename: 'assets/js/[name].test.bundle.js',
path: path.resolve(__dirname,'test/')
path: path.resolve(__dirname,'webtest/')
},
module: {
rules: [
Expand All @@ -22,42 +22,20 @@ module.exports = {
presets: ['env']
}
}
},
{
test: /\.(css|scss|sass)$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader!sass-loader!postcss-loader'
}),
},
{
test: /\.(jpe?g|png|jpg|gif)$/,
use: {
loader: 'file-loader',
options: {
name: '../images/[name].[ext]'
}
}
}
]
},
devServer: {
contentBase: path.join(__dirname, "test"),
contentBase: path.join(__dirname, "webtest"),
hot: true,
open: true
},
plugins: [
new HtmlWebpackPlugin({
title: 'Mocha test Runner',
hash: true,
template: './src/index.html'
template: './test/index.html'
}),
new ExtractTextPlugin('assets/css/[name].css'),
new webpack.HotModuleReplacementPlugin(),
new webpack.LoaderOptionsPlugin({
options: {
postcss: [autoprefixer]
}
})
new webpack.HotModuleReplacementPlugin()
]
};

0 comments on commit 131aa65

Please sign in to comment.