如何在提供创建反应应用程序应用程序后运行selenium?

时间:2017-08-08 14:39:52

标签: selenium react-native gruntjs create-react-app

我正在尝试使用selenium在我的Create React App应用程序上进行一些e2e测试。 问题是在selenium甚至可以运行之前,我必须自己运行react应用程序(例如使用npm start)。 问题是:提供应用程序将留在'观看'在我试图构建的任何autumation过程中的模式。

是否有可能运行创建反应应用程序,并且只有在那个硒之后? (使用grunt,npm或其他什么?)

目前的流程:

  1. 使用grunt运行react development server(使用npm start
  2. 运行selenium
  3. 有没有办法让它们一个接一个地工作?

    grunfile:

    需要(' dotenv&#39)。配置();

    module.exports = function(grunt){     const API = process.env.REACT_APP_API_PATH +':' + process.env.REACT_APP_API_PORT +' / api&#39 ;;     const DEV_PORT = 3001;

    grunt.initConfig({
        http: {
            prepare_e2e_tests: {
                options: {
                    url: API + '/prepare_e2e_tests'
                }
            }
        },
        exec: {
            start_dev_server: {
                cmd: 'REACT_APP_IS_TESTING=true PORT=' + DEV_PORT + ' npm start'
            },
            e2e: {
                cmd: 'DEV_SERVER_PORT=3001 npm run e2e'
            }
        },
        concurrent: {
            test: {
                tasks: ['http:prepare_e2e_tests','exec:start_dev_server','exec:e2e'],
                options: {
                    logConcurrentOutput: true
                }
            }
        }
    });
    
    grunt.registerTask('run_e2e', function() {
        console.log('running e2e tests');
        grutn.task.run('exec:e2e')
    });
    
    grunt.registerTask('prepare_server', function() {
        console.log('preparing e2e tests on server:');
        grunt.task.run('http:prepare_e2e_tests');
    });
    
    grunt.registerTask('setup_dev_server', function() {
        console.log('running development server on port ' + DEV_PORT);
        grunt.task.run('exec:start_dev_server');
    
    });
    
    grunt.registerTask('test', 'run e2e tests', ['concurrent:test']);
    
    grunt.loadNpmTasks('grunt-http');
    grunt.loadNpmTasks('grunt-exec');
    grunt.loadNpmTasks('grunt-concurrent');
    
    grunt.registerTask('default', []);
    

    };

    谢谢!

0 个答案:

没有答案