Mocha is a unittest framework for Node. In this document, we explain how you can test your javascript code and also your HTTP servers.
Use npm to install Mocha:
npm install mocha| import React from 'react'; | |
| import './App.css'; | |
| import Uploader from './components/Uploader'; | |
| import DisplayImage from './components/DisplayImage'; | |
| function App() { | |
| return ( | |
| <div className='App'> | |
| <Uploader /> | |
| <hr/> |
| import React, { Component } from 'react'; | |
| import axios from 'axios'; | |
| export default class DisplayImage extends Component { | |
| state = { message: '' }; | |
| formHandler = e => { | |
| e.preventDefault(); | |
| this.setState({ message: 'Loading...' }); | |
| const filename = document.querySelector('#filename').value; |
| import React, { Component } from 'react'; | |
| import axios from 'axios'; | |
| export default class Uploader extends Component { | |
| state = { | |
| message:'' | |
| }; | |
| getImage = e => { | |
| const files = e.target.files; |
| const express = require('express'); | |
| const app = express(); | |
| const cors = require('cors'); | |
| app.use(express.json()); | |
| app.use(cors()); | |
| const port = 3500; | |
| // Importing AWSPresigner |
| require('dotenv').config(); // Loading dotenv to have access to env variables | |
| const AWS = require('aws-sdk'); // Requiring AWS SDK. | |
| // Configuring AWS | |
| AWS.config = new AWS.Config({ | |
| accessKeyId: process.env.S3_KEY, // stored in the .env file | |
| secretAccessKey: process.env.S3_SECRET, // stored in the .env file | |
| region: process.env.BUCKET_REGION // This refers to your bucket configuration. | |
| }); |
Mocha is a unittest framework for Node. In this document, we explain how you can test your javascript code and also your HTTP servers.
Use npm to install Mocha:
npm install mocha