michaelthe / puppyjs Goto Github PK
View Code? Open in Web Editor NEWpuppeteer + jest + awesome-code = puppyjs
Home Page: https://puppyjs.com
License: MIT License
puppeteer + jest + awesome-code = puppyjs
Home Page: https://puppyjs.com
License: MIT License
Create a command so the user can create new tests using CLI.
For example $ puppy new test testname
should create a new file testname.pup.js
in e2e folder with basic structure like
describe('description', () => {
let page
beforeEach(async () => {
page = await puppy.newPage()
})
afterEach(async () => {
await page.close()
})
it('should ', async function () {
})
})
i believe we should move the colours to a separate file so that we can have a specific colour coding in logs
Since puppy uses these three options already in puppeteer for running tests, it would be good to have them exposed to the end user as well.
if you setup socket on a separate port cors doesn't work
use vuepress and netlify
Enrich the documentation and cover the following topics
Testing config
Available helper methods for testing
Available helper endpoints for development
I am looking to run puppyjs in serve mode using sockets.
It seems that the current implementation allows puppy to emit messages, but I don't see how to configure puppyjs to listen for a message (as you can with the http api). Is this possible? If so, are there any examples?
Right now puppy only support using uppercase methods for each route
example
'/api/user': {
headers: {
'Authorization': 'Bearer some-token'
},
'PATCH': {
body: 'hello from a PATCH'
}
}
to make puppy more robust it should work even when using 'patCh'
from
await puppy.register({path: '/api/user', method: 'patch', data: 'updated user'})
to
await puppy.register({path: '/api/user', method: 'patch', **body**: 'updated user'})
Due to human error, puppy.api.js might have syntax errors. Hence when puppy tries to reload the puppy.api.js it fails and the process exits.
Instead of defining the headers in the puppy.api.js
like the following
'/api/users': {
'GET': {
headers: [
{
key: 'X-Session-ID',
value: '234905823409578'
}
],
status: 200,
body: 'hello its a GET'
}
}
To this
'/api/users': {
'GET': {
headers: [
{
'X-Session-ID' : '234905823409578'
}
],
status: 200,
body: 'hello its a GET'
}
}
For example in an Angular app, you would use ng build -w
which will create a dist folder and puppy would server index.html
. However if you make changes to the angular app, you need to manually reload the page.
For convenience it would be great to have live-reload functionality.
Right now the flag is hardcoded for node --inspect
. User should have the ability to add it as an argument possibly as a --debug
flag.
verbose is not working properly
Instead of having our test files end in .e2e.js we can change that to .pup.js. Aside from "branding", the user might have other tests that end to .e2e.js and run by another tool in the same project.
Another requirement is that the user must be able to define the extension that puppy will recognise to run the tests by defining it in the puppy.config.js file and optionally add an argument to the command for the same.
e.g puppy test --ext-prefix=e2e
The default 'EMPTY-BODY' response is not JSON.stringified
which causes problems e.g with Angular HttpClient, it cannot parse the body.
The suggestion is to remove the default body completely.
Introduce a web socket spec for easily mocking web socket messages.
Sample file
const users = [
{name: 'Andrew', email: '[email protected]', age: 44},
{name: 'Kostis', email: '[email protected]', age: 35}
]
module.exports = [
{
delay: 1000,
interval: 1000,
messages: [
users,
{seen: false, createdAt: Date.now(), text: 'I am a notification'}
]
},
{
messages: async () => {
const items = [12,3,52,23]
return items[Math.floor(Math.random()*items.length)]
},
interval: 3000
}
]
Pull request #12
From this
const users = [
{name: 'Andrew', email: '[email protected]', age: 44},
{name: 'Kostis', email: '[email protected]', age: 35}
]
module.exports = [
{
delay: 1000,
interval: 1000,
messages: [
users,
{seen: false, createdAt: Date.now(), text: 'I am a notification'}
]
},
{
messages: async () => {
const items = [12,3,52,23]
return items[Math.floor(Math.random()*items.length)]
},
interval: 3000
}
]
To this
const users = [
{name: 'Andrew', email: '[email protected]', age: 44},
{name: 'Kostis', email: '[email protected]', age: 35}
]
module.exports = {
'notification': {
delay: 1000,
interval: 1000,
message: [
users,
{seen: false, createdAt: Date.now(), text: 'I am a notification'}
]
},
'randomNumber': {
interval: 3000,
message: async () => {
const items = [12, 3, 52, 23, 55]
return items[Math.floor(Math.random() * items.length)]
}
}
}
write more tests that will cover more cases eg.
file reloads
flash registered responses
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.