sinto 1.2.4 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gentest/generate.js +16 -0
- package/gentest/testPupContent.js +27 -0
- package/package.json +1 -1
- package/sin.js +2 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const { createFile, createDirectory } = require('../tools/tools.js');
|
|
2
|
+
const puppeteerTestContent = require('./testPupContent')
|
|
3
|
+
|
|
4
|
+
const createPuppeteerTest = () => {
|
|
5
|
+
const dir = process.cwd();
|
|
6
|
+
createDirectory(`${dir}/test`);
|
|
7
|
+
createFile(`${dir}/test/apptest.js`, puppeteerTestContent);
|
|
8
|
+
console.log('\n')
|
|
9
|
+
console.log('Install the dependencies:')
|
|
10
|
+
console.log(' npm install --save-dev puppeteer mocha')
|
|
11
|
+
console.log('Add start script to package.json:')
|
|
12
|
+
console.log(' \"test\": \"mocha\"')
|
|
13
|
+
console.log('\n')
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module.exports.createPuppeteerTest = createPuppeteerTest;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const puppeteerTestContent = `
|
|
2
|
+
import puppeteer from 'puppeteer'
|
|
3
|
+
import assert from 'assert'
|
|
4
|
+
|
|
5
|
+
describe('Weblap tartalmának tesztelése', () => {
|
|
6
|
+
let browser;
|
|
7
|
+
let page;
|
|
8
|
+
before(async function () {
|
|
9
|
+
browser = await puppeteer.launch({headless: true})
|
|
10
|
+
page = await browser.newPage()
|
|
11
|
+
await page.goto('http://localhost:3000')
|
|
12
|
+
})
|
|
13
|
+
after(async function() {
|
|
14
|
+
await browser.close()
|
|
15
|
+
})
|
|
16
|
+
it('Böngésző címsora', async function() {
|
|
17
|
+
const title = await page.title()
|
|
18
|
+
assert.strictEqual(title, 'Sinto Project')
|
|
19
|
+
})
|
|
20
|
+
it('h1 tartalma', async function() {
|
|
21
|
+
const content = await page.$eval('h1', element => element.textContent)
|
|
22
|
+
assert.strictEqual(content, 'Sinto Project')
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
`
|
|
27
|
+
module.exports = puppeteerTestContent
|
package/package.json
CHANGED
package/sin.js
CHANGED
|
@@ -7,6 +7,7 @@ const cli = require('./cli');
|
|
|
7
7
|
const serve = require('./server');
|
|
8
8
|
const { createApi } = require('./haiserver/apigen');
|
|
9
9
|
const { createWebpack } = require('./webpack/generate');
|
|
10
|
+
const { createPuppeteerTest } = require('./gentest/generate');
|
|
10
11
|
|
|
11
12
|
const {
|
|
12
13
|
createDirectory,
|
|
@@ -57,6 +58,7 @@ cli.command('build', 'Start build with gulp', {}, build);
|
|
|
57
58
|
cli.command('rmno', 'Delete node_modules directory', {}, rmno);
|
|
58
59
|
cli.command('api', 'REST API with hai-server', {}, createApi);
|
|
59
60
|
cli.command('webpack', 'Webpack client', {}, createWebpack);
|
|
61
|
+
cli.command('pup', 'Puppeteer test', {}, createPuppeteerTest);
|
|
60
62
|
|
|
61
63
|
const main = () => {
|
|
62
64
|
argv = cli.parse();
|