GithubHelp home page GithubHelp logo

roylh / mean Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 63.01 MB

MEAN Stack (MongoDB Express AngularJS Node.js)

Home Page: https://www.packtpub.com/product/mean-web-development-second-edition/9781785886300

JavaScript 80.68% HTML 6.86% EJS 12.46%

mean's Introduction

MEAN

MEAN Stack (MongoDB Express AngularJS Node.js)

ENV Install

Node.js 20.13.1

nvm install v20.13.1
nvm use v20.13.1

MongoDB latest

sudo docker run -p 27017:27017 --name mongo-container  \
-v ~/docker_home/mongo/data/configdb:/data/configdb \
-v ~/docker_home/mongo/data/db:/data/db \
-d mongo:latest \
--auth (加此项登录时需要用户名密码鉴权)

db.version() // 运行当前是7.0.9版本

sudo docker exec -it mongo-container mongosh admin

db.createUser({ 
 user: "root", 
 pwd: "123gogogo", 
 roles: [ 
  { role: "root", db: "admin" } 
 ] 
});

db.auth("root", "123gogogo");

Express

// see bower.json

AngularJS

// see package.json

Deps Install

npm install bower -g
bower install
// 如果下载错误 unzip public/lib.zip

npm install
// 如果下载错误 npm install --legacy-peer-deps
// 如果还下载错误 就解压目录里的压缩包node_modules.zip 项目比较久远 各个npm和node版本之间的依赖关系比较难梳理
// grunt-node-inspector 是在v6.17.1环境下下来的。。。
unzip node_modules.zip

Node Server Test

npm install mocha -g
NODE_ENV=test mocha --reporter spec app/tests

Angular Clint Unit Test

npm install karma-cli -g
NODE_ENV=test karma start

# 注意:karma-jasmine需要更新到2.0.0以上版本

Angular Clint E2E Test

npm install -g protractor
webdriver-manager update

NODE_ENV=test node server
protractor //新开命令行执行protractor

注意运行可能报错:

E/launcher - session not created: This version of ChromeDriver only supports Chrome version 114
Current browser version is 125.0.6422.77 with binary path /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

这是因为protractor npm已经不维护了,而protractor包中的: webdriver-manager/selenium目录下面只有chromedriver_114.0.5735.90版本的驱动

要解决这个问题 需要在protractor.conf.js文件中添加以下配置项

'use strict';

exports.config = {
  specs: ['public/*[!lib]*/tests/e2e/*.js'],
  // directConnect 选项用于直接连接到浏览器驱动程序(如 ChromeDriver 或 GeckoDriver)
  // 而不需要通过 Selenium Server 作为中间层。这可以简化测试环境的设置,并提高测试的启动速度和稳定性。
  directConnect: true,
  // capabilities 选项用于配置浏览器的特性和选项,它告诉 Protractor 在测试中应该如何启动和配置浏览器。
  capabilities: {
    // 这行配置指定了要使用的浏览器是 Chrome。
    browserName: 'chrome', 
    chromeOptions: {
      args: [
        // 禁用 GPU 硬件加速。这在某些情况下可以提高兼容性,尤其是在使用虚拟机或远程服务器时
        '--disable-gpu',
        // 设置浏览器窗口的大小为 800 像素宽和 600 像素高。这在需要以特定分辨率运行测试时特别有用 
        '--window-size=800,600' 
      ]
    }
  },
  // 手动下载和当前使用Chrome浏览器版本相匹配的驱动,将可执行文件放置在/usr/local/bin目录下,
  // 配置于chromeDriver选项中
  // 下载地址: https://developer.chrome.com/docs/chromedriver?hl=zh-cn
  chromeDriver: '/usr/local/bin/chromedriver', 
}

Grunt

npm i grunt-cli -g

mean's People

Contributors

roylh avatar

Watchers

 avatar

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.