Coder Social home page Coder Social logo

Add tests about esfiddle HOT 7 CLOSED

esfiddle avatar esfiddle commented on June 12, 2024
Add tests

from esfiddle.

Comments (7)

asiyani avatar asiyani commented on June 12, 2024

I have return 2 test cases for API testing on node side. Its for GET /fiddles/fiddle and POST /save. This test will only test node side like if fiddle is saved in db and correct fiddle is passed to client. I am not sure if this is what you looking for.

I am using mocha, chai and superTest for this.

While writing this test I found some issues I am not sure if its a bug for by Design.
--> Get /fiddles/fiddle should return 404 when fiddle is not found but its returning 200 and a message.
--> When we save same fiddle again it gets saved as another fiddle instead of updating original one.

I have commited my changes to this fork.

let me know if this is was you looking ?

from esfiddle.

joshghent avatar joshghent commented on June 12, 2024

@asiyani That's great work, thank you! If you can think of any more test cases to add (even if they fail) then go for it, the more the better! Only 1 thing is to add the npm run test-node to the npm test command so it will get run by the CI, but looks good!

The first issue, I will make an issue to fix that, so change the test to expect a 404 error.

The second issue is because we do not have logins for the site, we do not want anyone viewing a fiddle to be able to change it! Resaving functionality will be added once github signins are done.

Submit a PR and I'll merge it in 👍

from esfiddle.

asiyani avatar asiyani commented on June 12, 2024

@joshghent I am trying to submit pull request but it failing on travis test

Error message:- LINK
/home/travis/build/esfiddle/esfiddle/node_modules/mongodb/lib/url_parser.js:18
throw new Error('invalid schema, expected mongodb');

for this code....

mongo.connect(String(process.env.MONGODB_URI), function (err, db) { fiddles = db.collection('fiddles'); fiddles.insert(testFiddle); });

but this code is same as in api.js file. not sure why its failing api.test.js.. any idea ?

Thanks.

from esfiddle.

joshghent avatar joshghent commented on June 12, 2024

@asiyani I know the issue, submit the PR. It's ok if it's failing for now as we need to fix things like the 404 response etc. Submit the PR and I'll fix it up. I'll have a think of some more tests to add too.

from esfiddle.

asiyani avatar asiyani commented on June 12, 2024

Hi
I have submitted pull request.
travis test is still failing with 'Error: invalid schema, expected mongodb'.
Please let me know what is causing this issue.

If you think of any other test let me know.

Thanks

from esfiddle.

joshghent avatar joshghent commented on June 12, 2024

@asiyani it's caused by Travis not having the environment variables configured correctly. I'll fix it later, thanks for your PR. I'll take a look at this later

from esfiddle.

joshghent avatar joshghent commented on June 12, 2024

Fixed in #36

Thanks to @asiyani for his work and first PR 🎉

from esfiddle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.