简体   繁体   English

如何使用Angular.js前端对Django应用程序运行e2e测试场景?

[英]How can I run my e2e test scenario against a Django application with Angular.js frontend?

I want to do end to end test as described in the documentation Angular.js using a frontend based on angular-seed. 我想使用基于角度种子的前端按照文档Angular.js中的说明进行端到端测试。 The backend is written using django. 后端使用django编写。 When I try to use the jstestdriver (and the proxy option) I receive messages from jetty saying that GET requests to this URLs are not allowed. 当我尝试使用jstestdriver(和proxy选项)时,我收到码头的消息,说不允许对此URL进行GET请求。

How can I fix this? 我怎样才能解决这个问题? Are there other ways to run my tests in such a setup? 还有其他方法可以在这样的设置中运行测试吗?

Do I understand it correctly that it's just common Jasmine and the test driver is more or less just a server? 我是否正确理解它只是普通的茉莉花,而测试驱动程序或多或少只是一台服务器?

Karma is currently the supported test runner. Karma目前是受支持的测试运行程序。 Here's my testacular-e2e.conf.js file. 这是我的testacular-e2e.conf.js文件。

basePath = '../';

files = [
  ANGULAR_SCENARIO,
  ANGULAR_SCENARIO_ADAPTER,
  'test/e2e/**/*.js'
];


autoWatch = false;

browsers = ['Chrome'];

singleRun = true;

proxies = {
  '/': 'http://localhost:3000/'
};

junitReporter = {
  outputFile: 'test_out/e2e.xml',
  suite: 'e2e'
};

The important part is proxies . 重要的是proxies It configures testacular to use your server. 它配置testacular以使用您的服务器。 If I'm not mistaken, Django runs on port 8000 in development. 如果我没记错的话,Django在开发中的端口8000上运行。 So proxies would look like this: 因此proxies看起来像这样:

proxies = {
  '/': 'http://127.0.0.1:8000/'
};

After installing testacular via npm and creating this config file, you can then start your back end server and run your e2e tests like so: 通过npm安装testacular并创建此配置文件之后,您可以启动后端服务器并按以下方式运行e2e测试:

$ testacular start config/testacular-e2e.conf.js

JsTestDriver似乎不再被维护,您也可以尝试使用PhantomJS运行测试,例如: https : //github.com/jcarver989/phantom-jasmine

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何测试我的 django/react 应用程序的前端? - How do I test the frontend of my django/react app? django和angular.js与身份验证 - django and angular.js with authentication 如何针对测试数据库运行Selenium测试? - How can I run Selenium tests against a test database? 如何将 Django session 身份验证转移到我的 Vue 前端? - How can I transfer Django session authentication to my Vue frontend? 如何将图像添加到我的 django 数据库并在前端显示 - how can I add Image to my django database and display it in frontend 我如何使用文件中的 json 对象(例如 text.json)让我的电子邮件模板在 Django 中读取 - How I can use json object from file (e.g text.json) for my email template to read from in Django 如何使用 HTML/CSS/JS 前端和 Django 和 Flask 后端创建 Django Web 应用程序? - How do I create a Django web application with an HTML/CSS/JS frontend and a Django and Flask backend? 如何在Django测试客户端中创建补丁/更新(即更新对象)请求? - How to create a patch/update (i.e. update an object) request in Django test client? Django; 如何更改django.contrib.sessions使用的表名? - Django; How can i change the table name used by i.e django.contrib.sessions? 如何运行现有的 Django 应用程序? - How can I run an existing Django application?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM